mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 05:00:16 +00:00
Fix panic in vim search (#11022)
Release Notes: - vim: Fixed a panic when searching
This commit is contained in:
parent
1b614ef63b
commit
6d7332e80c
1 changed files with 11 additions and 1 deletions
|
@ -159,11 +159,21 @@ fn search_submit(workspace: &mut Workspace, _: &SearchSubmit, cx: &mut ViewConte
|
|||
search_bar.select_match(direction, count, cx);
|
||||
search_bar.focus_editor(&Default::default(), cx);
|
||||
|
||||
let prior_selections = state.prior_selections.drain(..).collect();
|
||||
let mut prior_selections: Vec<_> = state.prior_selections.drain(..).collect();
|
||||
let prior_mode = state.prior_mode;
|
||||
let prior_operator = state.prior_operator.take();
|
||||
let new_selections = vim.editor_selections(cx);
|
||||
|
||||
// If the active editor has changed during a search, don't panic.
|
||||
if prior_selections.iter().any(|s| {
|
||||
vim.update_active_editor(cx, |_vim, editor, cx| {
|
||||
!s.start.is_valid(&editor.snapshot(cx).buffer_snapshot)
|
||||
})
|
||||
.unwrap_or(true)
|
||||
}) {
|
||||
prior_selections.clear();
|
||||
}
|
||||
|
||||
if prior_mode != vim.state().mode {
|
||||
vim.switch_mode(prior_mode, true, cx);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue