mirror of
https://github.com/sharkdp/bat.git
synced 2025-03-15 15:18:45 +00:00
Formatted with newer cargo fmt.
It should pass all the checks now.
This commit is contained in:
parent
900f61032d
commit
d569693dab
@ -59,7 +59,7 @@ impl App {
|
|||||||
.use_delimiter(true)
|
.use_delimiter(true)
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.possible_values(&[
|
.possible_values(&[
|
||||||
"auto", "full", "plain", "changes", "header", "grid", "numbers"
|
"auto", "full", "plain", "changes", "header", "grid", "numbers",
|
||||||
])
|
])
|
||||||
.default_value("auto")
|
.default_value("auto")
|
||||||
.help("Additional info to display along with content"),
|
.help("Additional info to display along with content"),
|
||||||
|
@ -23,7 +23,8 @@ pub fn get_git_diff(filename: &str) -> Option<LineChanges> {
|
|||||||
diff_options.pathspec(pathspec);
|
diff_options.pathspec(pathspec);
|
||||||
diff_options.context_lines(0);
|
diff_options.context_lines(0);
|
||||||
|
|
||||||
let diff = repo.diff_index_to_workdir(None, Some(&mut diff_options))
|
let diff = repo
|
||||||
|
.diff_index_to_workdir(None, Some(&mut diff_options))
|
||||||
.ok()?;
|
.ok()?;
|
||||||
|
|
||||||
let mut line_changes: LineChanges = HashMap::new();
|
let mut line_changes: LineChanges = HashMap::new();
|
||||||
|
@ -19,11 +19,11 @@ extern crate syntect;
|
|||||||
|
|
||||||
mod app;
|
mod app;
|
||||||
mod assets;
|
mod assets;
|
||||||
|
mod decorations;
|
||||||
mod diff;
|
mod diff;
|
||||||
mod printer;
|
mod printer;
|
||||||
mod style;
|
mod style;
|
||||||
mod terminal;
|
mod terminal;
|
||||||
mod decorations;
|
|
||||||
|
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io::{self, BufRead, BufReader, Write};
|
use std::io::{self, BufRead, BufReader, Write};
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
use app::Config;
|
use app::Config;
|
||||||
|
use decorations::{Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration};
|
||||||
use diff::LineChanges;
|
use diff::LineChanges;
|
||||||
use errors::*;
|
use errors::*;
|
||||||
|
use std::boxed::Box;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
use std::boxed::Box;
|
use style::OutputWrap;
|
||||||
use syntect::highlighting;
|
use syntect::highlighting;
|
||||||
use terminal::as_terminal_escaped;
|
use terminal::as_terminal_escaped;
|
||||||
use style::OutputWrap;
|
|
||||||
use decorations::{Decoration, GridBorderDecoration, LineChangesDecoration, LineNumberDecoration};
|
|
||||||
use Colors;
|
use Colors;
|
||||||
|
|
||||||
pub struct Printer<'a> {
|
pub struct Printer<'a> {
|
||||||
@ -50,7 +50,9 @@ impl<'a> Printer<'a> {
|
|||||||
|
|
||||||
// Disable the panel if the terminal is too small (i.e. can't fit 5 characters with the
|
// Disable the panel if the terminal is too small (i.e. can't fit 5 characters with the
|
||||||
// panel showing).
|
// panel showing).
|
||||||
if config.term_width < (decorations.len() + decorations.iter().fold(0, |a, x| a + x.width())) + 5 {
|
if config.term_width
|
||||||
|
< (decorations.len() + decorations.iter().fold(0, |a, x| a + x.width())) + 5
|
||||||
|
{
|
||||||
decorations.clear();
|
decorations.clear();
|
||||||
panel_width = 0;
|
panel_width = 0;
|
||||||
}
|
}
|
||||||
@ -117,7 +119,8 @@ impl<'a> Printer<'a> {
|
|||||||
|
|
||||||
// Line decorations.
|
// Line decorations.
|
||||||
if self.panel_width > 0 {
|
if self.panel_width > 0 {
|
||||||
let decorations = self.decorations
|
let decorations = self
|
||||||
|
.decorations
|
||||||
.iter()
|
.iter()
|
||||||
.map(|ref d| d.generate(line_number, false, self))
|
.map(|ref d| d.generate(line_number, false, self))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
@ -29,10 +29,7 @@ impl BatTester {
|
|||||||
|
|
||||||
pub fn test_snapshot(&self, style: &str) {
|
pub fn test_snapshot(&self, style: &str) {
|
||||||
let output = Command::new(&self.exe)
|
let output = Command::new(&self.exe)
|
||||||
.args(&[
|
.args(&["tests/snapshots/sample.rs", &format!("--style={}", style)])
|
||||||
"tests/snapshots/sample.rs",
|
|
||||||
&format!("--style={}", style),
|
|
||||||
])
|
|
||||||
.output()
|
.output()
|
||||||
.expect("bat failed");
|
.expect("bat failed");
|
||||||
// have to do the replace because the filename in the header changes based on the current working directory
|
// have to do the replace because the filename in the header changes based on the current working directory
|
||||||
|
Loading…
x
Reference in New Issue
Block a user