1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-01 19:02:22 +01:00

Merge remote-tracking branch 'upstream/master' into feature-tabs

# Conflicts:
#	src/printer.rs
This commit is contained in:
eth-p
2018-09-11 14:03:47 -07:00
6 changed files with 65 additions and 9 deletions

View File

@@ -114,9 +114,13 @@ impl<'a> InteractivePrinter<'a> {
}
// Get the Git modifications
let line_changes = match file {
InputFile::Ordinary(filename) => get_git_diff(filename),
_ => None,
let line_changes = if config.output_components.changes() {
match file {
InputFile::Ordinary(filename) => get_git_diff(filename),
_ => None,
}
} else {
None
};
// Determine the type of syntax for highlighting
@@ -210,11 +214,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
line_buffer: &[u8],
) -> Result<()> {
let line = String::from_utf8_lossy(&line_buffer).to_string();
// Highlight.
let regions = self.highlighter.highlight(line.as_ref());
// Print.
if out_of_range {
return Ok(());
}
@@ -251,6 +252,10 @@ impl<'a> Printer for InteractivePrinter<'a> {
as_terminal_escaped(style, &*text, true_color, colored_output,)
)?;
}
if line.bytes().next_back() != Some(b'\n') {
write!(handle, "\n")?;
}
} else {
for &(style, region) in regions.iter() {
let mut ansi_iterator = AnsiCodeIterator::new(region);