From 0016876dc962dc15b65c0436d8c597d7e113bc3b Mon Sep 17 00:00:00 2001 From: Mika Vilpas Date: Mon, 29 Apr 2024 20:38:54 +0300 Subject: [PATCH] fix: avoiding duplicate candidates in the `which` component (#975) Co-authored-by: sxyazi --- yazi-core/src/which/commands/show.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/yazi-core/src/which/commands/show.rs b/yazi-core/src/which/commands/show.rs index 9a5ae428d..39f69c477 100644 --- a/yazi-core/src/which/commands/show.rs +++ b/yazi-core/src/which/commands/show.rs @@ -1,4 +1,4 @@ -use std::str::FromStr; +use std::{collections::HashSet, str::FromStr}; use yazi_config::{keymap::{Control, Key}, KEYMAP}; use yazi_shared::{event::Cmd, render, Layer}; @@ -43,12 +43,15 @@ impl Which { } pub fn show_with(&mut self, key: &Key, layer: Layer) { + let mut seen = HashSet::new(); + self.layer = layer; self.times = 1; self.cands = KEYMAP .get(layer) .iter() .filter(|c| c.on.len() > 1 && &c.on[0] == key) + .filter(|&c| seen.insert(&c.on)) .map(|c| c.into()) .collect();