Skip to content

Commit

Permalink
[vim] clear highlight timeout when exiting vim mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwing authored and marijnh committed Oct 29, 2021
1 parent c91fc40 commit eb6784c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions keymap/vim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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');
}
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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') {
Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit eb6784c

Please sign in to comment.