diff --git a/docs/changelog.md b/docs/changelog.md index 991bb1407..9b0c82dcf 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -64,6 +64,8 @@ As features stabilize some brief notes about them will accumulate here. * Closing a window while tab had a zoomed pane would leave the other panes untouched and wezterm would linger in the background [#2548](https://github.com/wez/wezterm/issues/2548) +* CharSelect panic when pressing enter when no matches were found + [#2580](https://github.com/wez/wezterm/issues/2580) #### Changed * Removed Last Resort fallback font diff --git a/wezterm-gui/src/termwindow/charselect.rs b/wezterm-gui/src/termwindow/charselect.rs index dab6b18e7..10b136fb7 100644 --- a/wezterm-gui/src/termwindow/charselect.rs +++ b/wezterm-gui/src/termwindow/charselect.rs @@ -599,11 +599,13 @@ impl Modal for CharSelector { (KeyCode::Enter, KeyModifiers::NONE) => { // Enter the selected character to the current pane let selected_idx = *self.selected_row.borrow(); - let alias_idx = self - .matches - .borrow() - .as_ref() - .map_or(selected_idx, |m| m.matches[selected_idx]); + let alias_idx = match self.matches.borrow().as_ref() { + None => return Ok(()), + Some(results) => match results.matches.get(selected_idx) { + Some(i) => *i, + None => return Ok(()), + } + }; let item = &self.aliases[alias_idx]; if let Err(err) = save_recent(item) { log::error!("Error while saving recents: {err:#}");