From 3acadaec1aa21f8a04befdaac6ea84429018f14b Mon Sep 17 00:00:00 2001 From: sxyazi Date: Sun, 24 Dec 2023 23:05:51 +0800 Subject: [PATCH] Format --- yazi-config/preset/keymap.toml | 6 +++--- yazi-config/preset/yazi.toml | 10 +++++----- yazi-config/src/popup/input.rs | 10 +++++----- yazi-config/src/popup/options.rs | 12 ++++++------ yazi-core/src/tab/commands/filter.rs | 6 ++---- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/yazi-config/preset/keymap.toml b/yazi-config/preset/keymap.toml index 00ed69da..9675fd11 100644 --- a/yazi-config/preset/keymap.toml +++ b/yazi-config/preset/keymap.toml @@ -89,15 +89,15 @@ keymap = [ { on = [ "c", "f" ], exec = "copy filename", desc = "Copy the name of the file" }, { on = [ "c", "n" ], exec = "copy name_without_ext", desc = "Copy the name of the file without the extension" }, + # Filter + { on = [ "f" ], exec = "filter" }, + # Find { on = [ "/" ], exec = "find --smart" }, { on = [ "?" ], exec = "find --previous --smart" }, { on = [ "n" ], exec = "find_arrow" }, { on = [ "N" ], exec = "find_arrow --previous" }, - # Filter - { on = [ "f" ], exec = "filter" }, - # Sorting { on = [ ",", "m" ], exec = "sort modified --dir_first", desc = "Sort by modified time" }, { on = [ ",", "M" ], exec = "sort modified --reverse --dir_first", desc = "Sort by modified time (reverse)" }, diff --git a/yazi-config/preset/yazi.toml b/yazi-config/preset/yazi.toml index c529be7b..bd5b4439 100644 --- a/yazi-config/preset/yazi.toml +++ b/yazi-config/preset/yazi.toml @@ -139,6 +139,11 @@ delete_title = "Delete {n} selected file{s} permanently? (y/N)" delete_origin = "top-center" delete_offset = [ 0, 2, 50, 3 ] +# filter +filter_title = "Filter:" +filter_origin = "top-center" +filter_offset = [ 0, 2, 50, 3 ] + # find find_title = [ "Find next:", "Find previous:" ] find_origin = "top-center" @@ -149,11 +154,6 @@ search_title = "Search:" search_origin = "top-center" search_offset = [ 0, 2, 50, 3 ] -# filter -filter_title = "Filter:" -filter_origin = "top-center" -filter_offset = [ 0, 2, 50, 3 ] - # shell shell_title = [ "Shell:", "Shell (block):" ] shell_origin = "top-center" diff --git a/yazi-config/src/popup/input.rs b/yazi-config/src/popup/input.rs index 1d07232d..4b1f9d52 100644 --- a/yazi-config/src/popup/input.rs +++ b/yazi-config/src/popup/input.rs @@ -30,16 +30,16 @@ pub struct Input { pub delete_origin: Origin, pub delete_offset: Offset, + // filter + pub filter_title: String, + pub filter_origin: Origin, + pub filter_offset: Offset, + // find pub find_title: [String; 2], pub find_origin: Origin, pub find_offset: Offset, - // filter - pub filter_title: String, - pub filter_origin: Origin, - pub filter_offset: Offset, - // search pub search_title: String, pub search_origin: Origin, diff --git a/yazi-config/src/popup/options.rs b/yazi-config/src/popup/options.rs index a6ce8496..9ef592e4 100644 --- a/yazi-config/src/popup/options.rs +++ b/yazi-config/src/popup/options.rs @@ -68,20 +68,20 @@ impl InputCfg { } #[inline] - pub fn find(prev: bool) -> Self { + pub fn filter() -> Self { Self { - title: INPUT.find_title[prev as usize].to_owned(), - position: Position::new(INPUT.find_origin, INPUT.find_offset), + title: INPUT.filter_title.to_owned(), + position: Position::new(INPUT.filter_origin, INPUT.filter_offset), realtime: true, ..Default::default() } } #[inline] - pub fn filter() -> Self { + pub fn find(prev: bool) -> Self { Self { - title: INPUT.filter_title.to_owned(), - position: Position::new(INPUT.filter_origin, INPUT.filter_offset), + title: INPUT.find_title[prev as usize].to_owned(), + position: Position::new(INPUT.find_origin, INPUT.find_offset), realtime: true, ..Default::default() } diff --git a/yazi-core/src/tab/commands/filter.rs b/yazi-core/src/tab/commands/filter.rs index 49d1070c..9da2c1ee 100644 --- a/yazi-core/src/tab/commands/filter.rs +++ b/yazi-core/src/tab/commands/filter.rs @@ -12,9 +12,7 @@ pub struct Opt<'a> { } impl<'a> From<&'a Exec> for Opt<'a> { - fn from(e: &'a Exec) -> Self { - Self { query: e.args.first().map(|s| s.as_str()) } - } + fn from(e: &'a Exec) -> Self { Self { query: e.args.first().map(|s| s.as_str()) } } } impl Tab { @@ -50,7 +48,7 @@ impl Tab { (None, Some(first)) => { self.current.hover(&first.url()); } - (_, _) => {} + (..) => {} } }