From 2faf44658c78441cb65166a1fdd047433047cdf2 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 29 Apr 2016 01:41:40 +0400 Subject: [PATCH] fix +13674 . command doesn't handle backspace in vim mode --- node_modules/ace/lib/ace/keyboard/vim.js | 30 ++++++++++++++---------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/node_modules/ace/lib/ace/keyboard/vim.js b/node_modules/ace/lib/ace/keyboard/vim.js index 9c295fb4..935a751e 100644 --- a/node_modules/ace/lib/ace/keyboard/vim.js +++ b/node_modules/ace/lib/ace/keyboard/vim.js @@ -154,17 +154,15 @@ define(function(require, exports, module) { return this.ace.inVirtualSelectionMode && this.ace.selection.index; }; this.onChange = function(delta) { - if (delta.action[0] == 'i') { - var change = { text: delta.lines }; - var curOp = this.curOp = this.curOp || {}; - if (!curOp.changeHandlers) - curOp.changeHandlers = this._eventRegistry["change"] && this._eventRegistry["change"].slice(); - if (this.virtualSelectionMode()) return; - if (!curOp.lastChange) { - curOp.lastChange = curOp.change = change; - } else { - curOp.lastChange.next = curOp.lastChange = change; - } + var change = { text: delta.action[0] == 'i' ? delta.lines : [] }; + var curOp = this.curOp = this.curOp || {}; + if (!curOp.changeHandlers) + curOp.changeHandlers = this._eventRegistry["change"] && this._eventRegistry["change"].slice(); + if (this.virtualSelectionMode()) return; + if (!curOp.lastChange) { + curOp.lastChange = curOp.change = change; + } else { + curOp.lastChange.next = curOp.lastChange = change; } this.$updateMarkers(delta); }; @@ -5693,6 +5691,10 @@ dom.importCssString(".normal-mode .ace_cursor{\ if (changeObj.origin == '+input' || changeObj.origin == 'paste' || changeObj.origin === undefined /* only in testing */) { var text = changeObj.text.join('\n'); + if (lastChange.maybeReset) { + lastChange.changes = []; + lastChange.maybeReset = false; + } lastChange.changes.push(text); } // Change objects may be chained with next. @@ -5715,7 +5717,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ lastChange.expectCursorActivityForChange = false; } else { // Cursor moved outside the context of an edit. Reset the change. - lastChange.changes = []; + lastChange.maybeReset = true; } } else if (!cm.curOp.isVimOp) { handleExternalSelection(cm, vim); @@ -5779,6 +5781,10 @@ dom.importCssString(".normal-mode .ace_cursor{\ var keyName = CodeMirror.keyName(e); if (!keyName) { return; } function onKeyFound() { + if (lastChange.maybeReset) { + lastChange.changes = []; + lastChange.maybeReset = false; + } lastChange.changes.push(new InsertModeKey(keyName)); return true; }