Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoheiu committed Jan 27, 2024
1 parent 5a983db commit 8879cc2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ impl Layout {
};

// Prepare state fields.
let session = read_session(session_path);
let (time_start, name_max) = make_layout(original_column);
let split = session.split.unwrap_or(Split::Vertical);
let session = read_session(session_path);
let split = session.split.unwrap_or_default();
let has_bat = check_bat();
let has_chafa = check_chafa();
let is_kitty = check_kitty_support();
Expand All @@ -94,10 +94,9 @@ impl Layout {
time_start_pos: time_start,
sort_by: session.sort_by,
show_hidden: session.show_hidden,
side: if session.preview.unwrap_or(false) {
Side::Preview
} else {
Side::None
side: match session.preview.unwrap_or(false) {
true => Side::Preview,
false => Side::None,
},
split,
preview_start: (0, 0),
Expand Down
6 changes: 3 additions & 3 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ impl State {

/// Set configuration from config file.
pub fn set_config(&mut self, config: Config) {
let color = config.color.unwrap_or_default();
self.match_vim_exit_behavior = config.match_vim_exit_behavior.unwrap_or_default();
self.default = config
.default
.unwrap_or_else(|| env::var("EDITOR").unwrap_or_default());
self.match_vim_exit_behavior = config.match_vim_exit_behavior.unwrap_or_default();
self.commands = to_extension_map(&config.exec);
self.layout.colors = color;
let colors = config.color.unwrap_or_default();
self.layout.colors = colors;
}

/// Select item that the cursor points to.
Expand Down

0 comments on commit 8879cc2

Please sign in to comment.