applay completion by `C-x`

If only one completion applay it by pressing completion hotkey
pull/12085/head
GladkihEgor 2025-07-21 19:45:40 +05:00
parent 7afdd1cc94
commit f61b72976e
1 changed files with 8 additions and 0 deletions

View File

@ -169,6 +169,10 @@ impl<T: Item> Menu<T> {
} }
pub fn selection(&self) -> Option<&T> { pub fn selection(&self) -> Option<&T> {
if self.options.len() == 1 {
return Some(&self.options[0]);
}
self.cursor.and_then(|cursor| { self.cursor.and_then(|cursor| {
self.matches self.matches
.get(cursor) .get(cursor)
@ -177,6 +181,10 @@ impl<T: Item> Menu<T> {
} }
pub fn selection_mut(&mut self) -> Option<&mut T> { pub fn selection_mut(&mut self) -> Option<&mut T> {
if self.options.len() == 1 {
return Some(&mut self.options[0]);
}
self.cursor.and_then(|cursor| { self.cursor.and_then(|cursor| {
self.matches self.matches
.get(cursor) .get(cursor)