From ebd57cea4432163a55bca371bf5e96438a6e061d Mon Sep 17 00:00:00 2001 From: gaesa <71256557+gaesa@users.noreply.github.com> Date: Sun, 9 Jun 2024 21:16:24 +0800 Subject: [PATCH] feat: support `enable` for which-key --- yazi-config/preset/yazi.toml | 5 +++-- yazi-config/src/which/which.rs | 1 + yazi-core/src/which/commands/show.rs | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/yazi-config/preset/yazi.toml b/yazi-config/preset/yazi.toml index 47b37cf2..5f805d07 100644 --- a/yazi-config/preset/yazi.toml +++ b/yazi-config/preset/yazi.toml @@ -185,10 +185,11 @@ open_origin = "hovered" open_offset = [ 0, 1, 50, 7 ] [which] +enable = true sort_by = "none" -sort_sensitive = false +sort_sensitive = false sort_reverse = false -sort_translit = false +sort_translit = false [log] enabled = false diff --git a/yazi-config/src/which/which.rs b/yazi-config/src/which/which.rs index 7d738870..240813c5 100644 --- a/yazi-config/src/which/which.rs +++ b/yazi-config/src/which/which.rs @@ -6,6 +6,7 @@ use crate::MERGED_YAZI; #[derive(Debug, Deserialize, Serialize, Validate)] pub struct Which { + pub enable: bool, // Sorting pub sort_by: SortBy, pub sort_sensitive: bool, diff --git a/yazi-core/src/which/commands/show.rs b/yazi-core/src/which/commands/show.rs index 39f69c47..ecafba27 100644 --- a/yazi-core/src/which/commands/show.rs +++ b/yazi-core/src/which/commands/show.rs @@ -1,6 +1,6 @@ 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 crate::which::{Which, WhichSorter}; @@ -43,6 +43,10 @@ impl Which { } pub fn show_with(&mut self, key: &Key, layer: Layer) { + if !WHICH.enable { + return; + } + let mut seen = HashSet::new(); self.layer = layer;