Skip to content

Commit eb6784c

Browse files
nightwingmarijnh
authored andcommitted
[vim] clear highlight timeout when exiting vim mode
1 parent c91fc40 commit eb6784c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

keymap/vim.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@
285285
cm.off('cursorActivity', onCursorActivity);
286286
CodeMirror.off(cm.getInputField(), 'paste', getOnPasteFn(cm));
287287
cm.state.vim = null;
288+
if (highlightTimeout) clearTimeout(highlightTimeout);
288289
}
289290

290291
function detachVimMap(cm, next) {
@@ -322,7 +323,7 @@
322323
if (!vimKey) {
323324
return false;
324325
}
325-
var cmd = CodeMirror.Vim.findKey(cm, vimKey);
326+
var cmd = vimApi.findKey(cm, vimKey);
326327
if (typeof cmd == 'function') {
327328
CodeMirror.signal(cm, 'vim-keypress', vimKey);
328329
}
@@ -877,7 +878,7 @@
877878
match = (/<\w+-.+?>|<\w+>|./).exec(keys);
878879
key = match[0];
879880
keys = keys.substring(match.index + key.length);
880-
CodeMirror.Vim.handleKey(cm, key, 'mapping');
881+
vimApi.handleKey(cm, key, 'mapping');
881882
}
882883
}
883884

@@ -965,7 +966,7 @@
965966
// clear VIM state in case it's in a bad state.
966967
cm.state.vim = undefined;
967968
maybeInitVimState(cm);
968-
if (!CodeMirror.Vim.suppressErrorLogging) {
969+
if (!vimApi.suppressErrorLogging) {
969970
console['log'](e);
970971
}
971972
throw e;
@@ -4411,6 +4412,7 @@
44114412
function highlightSearchMatches(cm, query) {
44124413
clearTimeout(highlightTimeout);
44134414
highlightTimeout = setTimeout(function() {
4415+
if (!cm.state.vim) return;
44144416
var searchState = getSearchState(cm);
44154417
var overlay = searchState.getOverlay();
44164418
if (!overlay || query != overlay.query) {
@@ -4605,7 +4607,7 @@
46054607
if (command.type == 'exToKey') {
46064608
// Handle Ex to Key mapping.
46074609
for (var i = 0; i < command.toKeys.length; i++) {
4608-
CodeMirror.Vim.handleKey(cm, command.toKeys[i], 'mapping');
4610+
vimApi.handleKey(cm, command.toKeys[i], 'mapping');
46094611
}
46104612
return;
46114613
} else if (command.type == 'exToEx') {
@@ -5458,7 +5460,7 @@
54585460
match = (/<\w+-.+?>|<\w+>|./).exec(text);
54595461
key = match[0];
54605462
text = text.substring(match.index + key.length);
5461-
CodeMirror.Vim.handleKey(cm, key, 'macro');
5463+
vimApi.handleKey(cm, key, 'macro');
54625464
if (vim.insertMode) {
54635465
var changes = register.insertModeChanges[imc++].changes;
54645466
vimGlobalState.macroModeState.lastInsertModeChanges.changes =

0 commit comments

Comments
 (0)