2dfffab549ca5cc734b644d8d85868979f7d3976
get_code_style_sections rebuilt the "path<sep>[line-number<sep>]" prefix from the parsed path and line number in order to find where the code starts in the raw line. That reconstruction can be shorter than the text which was actually printed: the parsed line number does not record the width of its own text, so an input "007" is rebuilt as "7", and a parsed path may contain a tab, which has already been expanded in the raw line. The slice then started inside the prefix, so the style sections described a different string than the parsed code, and superimpose panicked with "String mismatch encountered while superimposing style sections". Measure the prefix instead: the code is the tail of the line the parser was given, so the prefix is everything before it, and expanding its tabs gives its width in the tab-expanded raw line. For a well formed grep line the result is identical to the previous computation.
Languages
Rust
100%