mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2025-03-03 21:37:12 +00:00
fix(filter): prevent panic after tab completing
After tab completing if you would press a key other than return (enter) then the tui would panic, this change fixes that issue.
This commit is contained in:
parent
c12ae4a8ef
commit
de3d01922b
|
@ -92,8 +92,16 @@ impl Filter {
|
|||
let input = self.search_input.iter().collect::<String>().to_lowercase();
|
||||
self.items.iter().find_map(|item| {
|
||||
let item_name_lower = item.node.name.to_lowercase();
|
||||
(item_name_lower.starts_with(&input))
|
||||
.then_some(item_name_lower[input.len()..].to_string())
|
||||
item_name_lower
|
||||
.starts_with(&input)
|
||||
.then(|| {
|
||||
if input.len() <= item_name_lower.len() {
|
||||
Some(item_name_lower[input.len()..].to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.flatten()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user