1
1
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:
Wez Furlong 2022-10-15 08:55:11 -07:00
parent 7cc91696e9
commit b2e901ecd3
2 changed files with 22 additions and 12 deletions

View File

@ -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

View File

@ -411,12 +411,17 @@ impl LauncherState {
term.render(&changes)
}
fn launch(&self, active_idx: usize) {
let assignment = self.filtered_entries[active_idx].action.clone();
self.window.notify(TermWindowNotif::PerformAssignment {
pane_id: self.pane_id,
assignment,
});
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,8 +445,9 @@ 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);
break;
if self.launch(self.top_row + (c as u32 - '1' as u32) as usize) {
break;
}
}
InputEvent::Key(KeyEvent {
key: KeyCode::Char('j'),
@ -538,8 +544,9 @@ impl LauncherState {
self.active_idx = self.top_row + y as usize - 1;
if mouse_buttons == MouseButtons::LEFT {
self.launch(self.active_idx);
break;
if self.launch(self.active_idx) {
break;
}
}
}
if mouse_buttons != MouseButtons::NONE {
@ -551,8 +558,9 @@ impl LauncherState {
key: KeyCode::Enter,
..
}) => {
self.launch(self.active_idx);
break;
if self.launch(self.active_idx) {
break;
}
}
InputEvent::Resized { rows, .. } => {
self.max_items = rows.saturating_sub(ROW_OVERHEAD);