diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index ecd9a9e6..cddb2106 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -66,6 +66,10 @@ var TextInput = function(parentNode, host) { host.onTextInput(value); } else host.onTextInput(value); + + // If editor is no longer focused we quit immediately, since + // it means that something else like CLI is in charge now. + if (!isFocused()) return false; } } copied = false; @@ -221,6 +225,11 @@ var TextInput = function(parentNode, host) { text.blur(); }; + function isFocused() { + return document.activeElement === text; + }; + this.isFocused = isFocused; + this.getElement = function() { return text; };