Skip to content

Commit

Permalink
fix: avoiding duplicate candidates in the which component (#975)
Browse files Browse the repository at this point in the history
Co-authored-by: sxyazi <sxyazi@gmail.com>
  • Loading branch information
mikavilpas and sxyazi committed Apr 29, 2024
1 parent 3a09155 commit 0016876
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion yazi-core/src/which/commands/show.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 0016876

Please sign in to comment.