Skip to content

Commit

Permalink
Remove preview from JsonViewer::new, set it elsewhere
Browse files Browse the repository at this point in the history
This is used in lots of places, so it's not worth changing every single
call to `::new()` just to add `preview`. Just set it right after `::new`
in app.rs and let it default everywhere else.
  • Loading branch information
brewingcode committed Feb 16, 2022
1 parent 1e6dbc1 commit f7e2c0b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ impl App {
Err(err) => return Err(format!("Unable to parse input: {:?}", err)),
};

let mut viewer = JsonViewer::new(flatjson, opt.mode, opt.preview);
let mut viewer = JsonViewer::new(flatjson, opt.mode);
viewer.preview = opt.preview;
viewer.scrolloff_setting = opt.scrolloff;

let screen_writer =
Expand Down
4 changes: 2 additions & 2 deletions src/viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct JsonViewer {
}

impl JsonViewer {
pub fn new(flatjson: FlatJson, mode: Mode, preview: Preview) -> JsonViewer {
pub fn new(flatjson: FlatJson, mode: Mode) -> JsonViewer {
JsonViewer {
flatjson,
top_row: 0,
Expand All @@ -45,7 +45,7 @@ impl JsonViewer {
dimensions: TTYDimensions::default(),
scrolloff_setting: DEFAULT_SCROLLOFF,
mode,
preview,
preview: Preview::Full,
}
}
}
Expand Down

0 comments on commit f7e2c0b

Please sign in to comment.