mirror of
https://github.com/dandavison/delta.git
synced 2026-10-12 02:12:41 +00:00
Fix classic grep format writing file:line: prefix directly to writer
The classic grep format handler wrote file:line: prefixes and navigate markers directly to painter.writer, bypassing output_buffer. When context-lines is active, emit() snapshots output_buffer instead of flushing to writer, so the direct writes arrived before the buffered code lines, concatenating all prefixes on one line. Fix: write prefixes to output_buffer so they stay ordered with the code they precede, regardless of whether emit() flushes immediately or snapshots for context narrowing.
This commit is contained in:
@@ -270,9 +270,7 @@ impl StateMachine<'_> {
|
||||
}
|
||||
_ => {
|
||||
if self.config.navigate {
|
||||
write!(
|
||||
self.painter.writer,
|
||||
"{}",
|
||||
self.painter.output_buffer.push_str(
|
||||
match (
|
||||
&grep_line.line_type,
|
||||
OUTPUT_CONFIG.add_navigate_marker_to_matches
|
||||
@@ -281,7 +279,7 @@ impl StateMachine<'_> {
|
||||
(_, true) => " ",
|
||||
_ => "",
|
||||
}
|
||||
)?
|
||||
)
|
||||
}
|
||||
self._emit_classic_format_file_and_line_number(&grep_line)?;
|
||||
self._emit_classic_format_code(grep_line)?;
|
||||
@@ -306,10 +304,8 @@ impl StateMachine<'_> {
|
||||
// ":" for matches and non-matches alike.
|
||||
&self.config.grep_separator_symbol
|
||||
};
|
||||
write!(
|
||||
self.painter.writer,
|
||||
"{}",
|
||||
paint::paint_file_path_with_line_number(
|
||||
self.painter.output_buffer.push_str(
|
||||
&paint::paint_file_path_with_line_number(
|
||||
grep_line.line_number,
|
||||
&grep_line.path,
|
||||
OUTPUT_CONFIG.pad_line_number,
|
||||
@@ -319,7 +315,7 @@ impl StateMachine<'_> {
|
||||
Some(self.config.grep_line_number_style),
|
||||
self.config
|
||||
)
|
||||
)?;
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user