Skip to content

Commit db337cb

Browse files
zxvfcsylvestre
authored andcommitted
Make side_diff use separate set of formatting params
1 parent 382b016 commit db337cb

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/diff.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,16 @@ pub fn main(opts: Peekable<ArgsOs>) -> ExitCode {
6161
}),
6262
Format::SideBySide => {
6363
let mut output = stdout().lock();
64-
side_diff::diff(&from_content, &to_content, &mut output, &params)
64+
side_diff::diff(
65+
&from_content,
66+
&to_content,
67+
&mut output,
68+
&side_diff::Params {
69+
tabsize: params.tabsize,
70+
width: params.width,
71+
expand_tabs: params.expand_tabs,
72+
},
73+
)
6574
}
6675
};
6776
if params.brief && !result.is_empty() {

src/side_diff.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ use diff::Result;
88
use std::{io::Write, vec};
99
use unicode_width::UnicodeWidthStr;
1010

11-
use crate::params::Params;
12-
1311
const GUTTER_WIDTH_MIN: usize = 3;
1412

1513
struct CharIter<'a> {
@@ -306,6 +304,13 @@ fn push_output<T: Write>(
306304
Ok(())
307305
}
308306

307+
#[derive(Default)]
308+
pub struct Params {
309+
pub width: usize,
310+
pub tabsize: usize,
311+
pub expand_tabs: bool,
312+
}
313+
309314
pub fn diff<T: Write>(
310315
from_file: &[u8],
311316
to_file: &[u8],

0 commit comments

Comments
 (0)