1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-12 08:12:27 +01:00

Added tab expansion preprocessing step.

This commit is contained in:
eth-p
2018-09-10 18:11:59 -07:00
parent 8b4abb03db
commit b23ff24ebc
4 changed files with 64 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ use decorations::{Decoration, GridBorderDecoration, LineChangesDecoration, LineN
use diff::get_git_diff;
use diff::LineChanges;
use errors::*;
use preprocessor::expand;
use style::OutputWrap;
use terminal::{as_terminal_escaped, to_ansi_color};
@@ -200,9 +201,17 @@ impl<'a> Printer for InteractivePrinter<'a> {
line_number: usize,
line_buffer: &[u8],
) -> Result<()> {
let line = String::from_utf8_lossy(&line_buffer);
let mut line = String::from_utf8_lossy(&line_buffer).to_string();
// Preprocess.
if self.config.tab_width > 0 {
line = expand(&line, self.config.tab_width);
}
// Highlight.
let regions = self.highlighter.highlight(line.as_ref());
// Print.
if out_of_range {
return Ok(());
}