mirror of
https://github.com/wez/wezterm.git
synced 2024-09-21 11:50:42 +03:00
launcher: don't panic when launching nothing
refs: https://github.com/wez/wezterm/issues/2629
This commit is contained in:
parent
7cc91696e9
commit
b2e901ecd3
@ -92,6 +92,8 @@ As features stabilize some brief notes about them will accumulate here.
|
||||
[#2568](https://github.com/wez/wezterm/issues/2568)
|
||||
* Incorrect shaping for U+28 U+FF9F
|
||||
[#2572](https://github.com/wez/wezterm/issues/2572)
|
||||
* Panic when hitting enter in launcher menu when no fuzzy results match
|
||||
[#2629](https://github.com/wez/wezterm/issues/2629)
|
||||
|
||||
#### Changed
|
||||
* Removed Last Resort fallback font
|
||||
|
@ -411,12 +411,17 @@ impl LauncherState {
|
||||
term.render(&changes)
|
||||
}
|
||||
|
||||
fn launch(&self, active_idx: usize) {
|
||||
let assignment = self.filtered_entries[active_idx].action.clone();
|
||||
fn launch(&self, active_idx: usize) -> bool {
|
||||
if let Some(entry) = self.filtered_entries.get(active_idx) {
|
||||
let assignment = entry.action.clone();
|
||||
self.window.notify(TermWindowNotif::PerformAssignment {
|
||||
pane_id: self.pane_id,
|
||||
assignment,
|
||||
});
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn move_up(&mut self) {
|
||||
@ -440,9 +445,10 @@ impl LauncherState {
|
||||
key: KeyCode::Char(c),
|
||||
..
|
||||
}) if !self.filtering && c >= '1' && c <= '9' => {
|
||||
self.launch(self.top_row + (c as u32 - '1' as u32) as usize);
|
||||
if self.launch(self.top_row + (c as u32 - '1' as u32) as usize) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
InputEvent::Key(KeyEvent {
|
||||
key: KeyCode::Char('j'),
|
||||
..
|
||||
@ -538,10 +544,11 @@ impl LauncherState {
|
||||
self.active_idx = self.top_row + y as usize - 1;
|
||||
|
||||
if mouse_buttons == MouseButtons::LEFT {
|
||||
self.launch(self.active_idx);
|
||||
if self.launch(self.active_idx) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if mouse_buttons != MouseButtons::NONE {
|
||||
// Treat any other mouse button as cancel
|
||||
break;
|
||||
@ -551,9 +558,10 @@ impl LauncherState {
|
||||
key: KeyCode::Enter,
|
||||
..
|
||||
}) => {
|
||||
self.launch(self.active_idx);
|
||||
if self.launch(self.active_idx) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
InputEvent::Resized { rows, .. } => {
|
||||
self.max_items = rows.saturating_sub(ROW_OVERHEAD);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user