mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: avoiding duplicate candidates in the which component (#975)
Co-authored-by: sxyazi <sxyazi@gmail.com>
This commit is contained in:
parent
3a09155328
commit
0016876dc9
1 changed files with 4 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
use std::str::FromStr;
|
use std::{collections::HashSet, str::FromStr};
|
||||||
|
|
||||||
use yazi_config::{keymap::{Control, Key}, KEYMAP};
|
use yazi_config::{keymap::{Control, Key}, KEYMAP};
|
||||||
use yazi_shared::{event::Cmd, render, Layer};
|
use yazi_shared::{event::Cmd, render, Layer};
|
||||||
|
|
@ -43,12 +43,15 @@ impl Which {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn show_with(&mut self, key: &Key, layer: Layer) {
|
pub fn show_with(&mut self, key: &Key, layer: Layer) {
|
||||||
|
let mut seen = HashSet::new();
|
||||||
|
|
||||||
self.layer = layer;
|
self.layer = layer;
|
||||||
self.times = 1;
|
self.times = 1;
|
||||||
self.cands = KEYMAP
|
self.cands = KEYMAP
|
||||||
.get(layer)
|
.get(layer)
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|c| c.on.len() > 1 && &c.on[0] == key)
|
.filter(|c| c.on.len() > 1 && &c.on[0] == key)
|
||||||
|
.filter(|&c| seen.insert(&c.on))
|
||||||
.map(|c| c.into())
|
.map(|c| c.into())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue