From 07c99e05414698373349116780fd15e2cd955d93 Mon Sep 17 00:00:00 2001 From: Aaron O'Mullan Date: Tue, 28 Jan 2014 00:52:55 +0100 Subject: [PATCH] Fix: skip auto magic completion when pasting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This can some times cause confusing behavior. A paste is any text insertion of more than one character at a time … --- lib/ace/ext/language_tools.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/ace/ext/language_tools.js b/lib/ace/ext/language_tools.js index e7cb1fba..0e12e4df 100644 --- a/lib/ace/ext/language_tools.js +++ b/lib/ace/ext/language_tools.js @@ -120,6 +120,20 @@ var onChangeAutocomplete = function(e, editor) { var pos = editor.getCursorPosition(); var line = session.getLine(pos.row); + // Detect paste (poor man's paste detection) + var pasting = ( + ( + e.data.action === 'insertText' && + e.data.text.length > 1 + ) || + e.data.action === 'insertLines' + ); + + // we don't want to autocomplete on paste events + if(pasting) { + return; + } + // Append added text to the line if(e.data.action === 'insertText') { line += e.data.text;