feat: support enable for which-key

This commit is contained in:
gaesa 2024-06-09 21:16:24 +08:00
parent 189cb81db3
commit ebd57cea44
No known key found for this signature in database
3 changed files with 9 additions and 3 deletions

View file

@ -185,10 +185,11 @@ open_origin = "hovered"
open_offset = [ 0, 1, 50, 7 ] open_offset = [ 0, 1, 50, 7 ]
[which] [which]
enable = true
sort_by = "none" sort_by = "none"
sort_sensitive = false sort_sensitive = false
sort_reverse = false sort_reverse = false
sort_translit = false sort_translit = false
[log] [log]
enabled = false enabled = false

View file

@ -6,6 +6,7 @@ use crate::MERGED_YAZI;
#[derive(Debug, Deserialize, Serialize, Validate)] #[derive(Debug, Deserialize, Serialize, Validate)]
pub struct Which { pub struct Which {
pub enable: bool,
// Sorting // Sorting
pub sort_by: SortBy, pub sort_by: SortBy,
pub sort_sensitive: bool, pub sort_sensitive: bool,

View file

@ -1,6 +1,6 @@
use std::{collections::HashSet, str::FromStr}; use std::{collections::HashSet, str::FromStr};
use yazi_config::{keymap::{Control, Key}, KEYMAP}; use yazi_config::{keymap::{Control, Key}, KEYMAP, WHICH};
use yazi_shared::{event::Cmd, render, Layer}; use yazi_shared::{event::Cmd, render, Layer};
use crate::which::{Which, WhichSorter}; use crate::which::{Which, WhichSorter};
@ -43,6 +43,10 @@ impl Which {
} }
pub fn show_with(&mut self, key: &Key, layer: Layer) { pub fn show_with(&mut self, key: &Key, layer: Layer) {
if !WHICH.enable {
return;
}
let mut seen = HashSet::new(); let mut seen = HashSet::new();
self.layer = layer; self.layer = layer;