From eb6784c4d30e50e38fb390d10557e7928f8ebe4c Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 29 Oct 2021 02:23:14 +0400 Subject: [PATCH] [vim] clear highlight timeout when exiting vim mode --- keymap/vim.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/keymap/vim.js b/keymap/vim.js index 8491a49314..461cfc1b5c 100644 --- a/keymap/vim.js +++ b/keymap/vim.js @@ -285,6 +285,7 @@ cm.off('cursorActivity', onCursorActivity); CodeMirror.off(cm.getInputField(), 'paste', getOnPasteFn(cm)); cm.state.vim = null; + if (highlightTimeout) clearTimeout(highlightTimeout); } function detachVimMap(cm, next) { @@ -322,7 +323,7 @@ if (!vimKey) { return false; } - var cmd = CodeMirror.Vim.findKey(cm, vimKey); + var cmd = vimApi.findKey(cm, vimKey); if (typeof cmd == 'function') { CodeMirror.signal(cm, 'vim-keypress', vimKey); } @@ -877,7 +878,7 @@ match = (/<\w+-.+?>|<\w+>|./).exec(keys); key = match[0]; keys = keys.substring(match.index + key.length); - CodeMirror.Vim.handleKey(cm, key, 'mapping'); + vimApi.handleKey(cm, key, 'mapping'); } } @@ -965,7 +966,7 @@ // clear VIM state in case it's in a bad state. cm.state.vim = undefined; maybeInitVimState(cm); - if (!CodeMirror.Vim.suppressErrorLogging) { + if (!vimApi.suppressErrorLogging) { console['log'](e); } throw e; @@ -4411,6 +4412,7 @@ function highlightSearchMatches(cm, query) { clearTimeout(highlightTimeout); highlightTimeout = setTimeout(function() { + if (!cm.state.vim) return; var searchState = getSearchState(cm); var overlay = searchState.getOverlay(); if (!overlay || query != overlay.query) { @@ -4605,7 +4607,7 @@ if (command.type == 'exToKey') { // Handle Ex to Key mapping. for (var i = 0; i < command.toKeys.length; i++) { - CodeMirror.Vim.handleKey(cm, command.toKeys[i], 'mapping'); + vimApi.handleKey(cm, command.toKeys[i], 'mapping'); } return; } else if (command.type == 'exToEx') { @@ -5458,7 +5460,7 @@ match = (/<\w+-.+?>|<\w+>|./).exec(text); key = match[0]; text = text.substring(match.index + key.length); - CodeMirror.Vim.handleKey(cm, key, 'macro'); + vimApi.handleKey(cm, key, 'macro'); if (vim.insertMode) { var changes = register.insertModeChanges[imc++].changes; vimGlobalState.macroModeState.lastInsertModeChanges.changes =