Merge pull request #2418 from zed-industries/vim-inactive-window-crash

Fix vim mode crash when active editor changes in inactive window
This commit is contained in:
Max Brunsfeld 2023-04-27 10:48:49 -07:00 committed by GitHub
commit 45c7073934
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,11 +9,18 @@ pub fn init(cx: &mut AppContext) {
}
fn focused(EditorFocused(editor): &EditorFocused, cx: &mut AppContext) {
if let Some(previously_active_editor) = Vim::read(cx).active_editor.clone() {
cx.update_window(previously_active_editor.window_id(), |cx| {
Vim::update(cx, |vim, cx| {
vim.update_active_editor(cx, |previously_active_editor, cx| {
Vim::unhook_vim_settings(previously_active_editor, cx);
});
});
});
}
cx.update_window(editor.window_id(), |cx| {
Vim::update(cx, |vim, cx| {
vim.update_active_editor(cx, |previously_active_editor, cx| {
Vim::unhook_vim_settings(previously_active_editor, cx);
});
vim.set_active_editor(editor.clone(), cx);
});
});