fix charselect panic when pressing enter on no matches

refs: https://github.com/wez/wezterm/issues/2580
This commit is contained in:
Wez Furlong committed 2022-10-04 09:09:47 -07:00
1 parent 6d0e3d9caf
commit 1a4749940b
2 files changed
+9 -5

No files matched your search

+2
View File
@@ -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
+7 -5
View File
@@ -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:#}");