diff --git a/lib/ace/autocomplete.js b/lib/ace/autocomplete.js index f3800c16..6e064381 100644 --- a/lib/ace/autocomplete.js +++ b/lib/ace/autocomplete.js @@ -283,8 +283,7 @@ var Autocomplete = function() { // if (matches.length == 1) // return this.insertMatch(matches[0]); - // No prefix or no results -> close - if (!prefix || !prefix.length || !matches || !matches.length) + if (!matches || !matches.length) return doDetach(); // Wrong prefix or wrong session -> ignore diff --git a/lib/ace/ext/language_tools.js b/lib/ace/ext/language_tools.js index 0f9be6b9..6c1182a1 100644 --- a/lib/ace/ext/language_tools.js +++ b/lib/ace/ext/language_tools.js @@ -117,53 +117,32 @@ var loadSnippetFile = function(id) { var doLiveAutocomplete = function(e) { var editor = e.editor; - var session = editor.getSession(); - var pos = editor.getCursorPosition(); - var line = session.getLine(pos.row); - var hasCompleter = (editor.completer && editor.completer.activated); - var text = e.args || ""; - - // Is the user entering text - // we only want to automatically show the autocomplete dialog - // whenever the user is typing in text not pasting, deleting, ... - var typing = (e.command.name === "insertstring" && text.length === 1); - - // We don't want to autocomplete with no prefix - if( - e.command.name === 'backspace' && - util.retrievePrecedingIdentifier(line, pos.column) === '' - ) { - if(hasCompleter) editor.completer.detach(); - return; - } - - // we don't want to autocomplete on paste events - if(!typing) { - return; - } - - // The prefix to autocomplete for + var pos = editor.getCursorPosition(); + var line = editor.session.getLine(pos.row); + var hasCompleter = editor.completer && editor.completer.activated; var prefix = util.retrievePrecedingIdentifier(line, pos.column); - // Only autocomplete if there's a prefix that can be matched - if(prefix !== '' && !(hasCompleter)) { - if (!editor.completer) { - // Create new autocompleter - editor.completer = new Autocomplete(); - - // Disable autoInsert - editor.completer.autoInsert = false; + // We don't want to autocomplete with no prefix + if (e.command.name === "backspace" && !prefix) { + if (hasCompleter) + editor.completer.detach(); + } + else if (e.command.name === "insertstring") { + // Only autocomplete if there's a prefix that can be matched + if (prefix && !hasCompleter) { + if (!editor.completer) { + // Create new autocompleter + editor.completer = new Autocomplete(); + // Disable autoInsert + editor.completer.autoInsert = false; + } + editor.completer.showPopup(editor); + } else if (!prefix && hasCompleter) { + // When the prefix is empty + // close the autocomplete dialog + editor.completer.detach(); } - - editor.completer.showPopup(editor); - // needed for firefox on mac - editor.completer.cancelContextMenu(); - - } else if(prefix === '' && hasCompleter) { - // When the prefix is empty - // close the autocomplete dialog - editor.completer.detach(); } }; diff --git a/lib/ace/snippets/javascript.js b/lib/ace/snippets/javascript.js index ed832d74..bf59ba85 100644 --- a/lib/ace/snippets/javascript.js +++ b/lib/ace/snippets/javascript.js @@ -1,9 +1,7 @@ define(function(require, exports, module) { "use strict"; -exports.snippetText = require("../requirejs/text!./javascript-jquery.snippets") - + "\n" - + require("../requirejs/text!./javascript.snippets"); +exports.snippetText = require("../requirejs/text!./javascript.snippets"); exports.scope = "javascript"; });