mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-12 16:10:07 +01:00
refactor: view: un-nest trie processing
This commit is contained in:
parent
fb07f64c97
commit
57f032af7c
1 changed files with 22 additions and 21 deletions
43
src/view.rs
43
src/view.rs
|
|
@ -436,28 +436,29 @@ impl<'a> View<'a> {
|
||||||
|
|
||||||
typed_hint.push_str(&lower_key);
|
typed_hint.push_str(&lower_key);
|
||||||
|
|
||||||
match self
|
let node = self
|
||||||
.lookup_trie
|
.lookup_trie
|
||||||
.get_node(&typed_hint.chars().collect::<Vec<char>>())
|
.get_node(&typed_hint.chars().collect::<Vec<char>>());
|
||||||
{
|
|
||||||
None => {
|
if node.is_none() {
|
||||||
// An unknown key was entered.
|
// An unknown key was entered.
|
||||||
return Event::Exit;
|
return Event::Exit;
|
||||||
}
|
}
|
||||||
Some(node) => {
|
|
||||||
if node.is_leaf() {
|
let node = node.unwrap();
|
||||||
// The last key of a hint was entered.
|
if node.is_leaf() {
|
||||||
let match_index = node.value().expect("By construction, the Lookup Trie should have a value for each leaf.");
|
// The last key of a hint was entered.
|
||||||
let mat = self.matches.get(*match_index).expect("By construction, the value in a leaf should correspond to an existing hint.");
|
let match_index = node.value().expect(
|
||||||
let text = mat.text.to_string();
|
"By construction, the Lookup Trie should have a value for each leaf.",
|
||||||
let uppercased = key != lower_key;
|
);
|
||||||
return Event::Match((text, uppercased));
|
let mat = self.matches.get(*match_index).expect("By construction, the value in a leaf should correspond to an existing hint.");
|
||||||
} else {
|
let text = mat.text.to_string();
|
||||||
// The prefix of a hint was entered, but we
|
let uppercased = key != lower_key;
|
||||||
// still need more keys.
|
return Event::Match((text, uppercased));
|
||||||
continue;
|
} else {
|
||||||
}
|
// The prefix of a hint was entered, but we
|
||||||
}
|
// still need more keys.
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue