vendor/assets/javascripts/ace/ext-language_tools.js in ace-rails-ap-4.0.1 vs vendor/assets/javascripts/ace/ext-language_tools.js in ace-rails-ap-4.0.2
- old
+ new
@@ -1102,11 +1102,11 @@
popup.getRow = function() {
return selectionMarker.start.row;
};
popup.setRow = function(line) {
- line = Math.max(-1, Math.min(this.data.length, line));
+ line = Math.max(0, Math.min(this.data.length, line));
if (selectionMarker.start.row != line) {
popup.selection.clearSelection();
selectionMarker.start.row = selectionMarker.end.row = line || 0;
popup.session._emit("changeBackMarker");
popup.moveCursorTo(line || 0, 0);
@@ -1255,10 +1255,25 @@
break;
}
return buf;
};
+exports.getCompletionPrefix = function (editor) {
+ var pos = editor.getCursorPosition();
+ var line = editor.session.getLine(pos.row);
+ var prefix;
+ editor.completers.forEach(function(completer) {
+ if (completer.identifierRegexps) {
+ completer.identifierRegexps.forEach(function(identifierRegex) {
+ if (!prefix && identifierRegex)
+ prefix = this.retrievePrecedingIdentifier(line, pos.column, identifierRegex);
+ }.bind(this));
+ }
+ }.bind(this));
+ return prefix || this.retrievePrecedingIdentifier(line, pos.column);
+};
+
});
define("ace/autocomplete",["require","exports","module","ace/keyboard/hash_handler","ace/autocomplete/popup","ace/autocomplete/util","ace/lib/event","ace/lib/lang","ace/lib/dom","ace/snippets"], function(require, exports, module) {
"use strict";
@@ -1452,25 +1467,25 @@
this.gatherCompletions = function(editor, callback) {
var session = editor.getSession();
var pos = editor.getCursorPosition();
var line = session.getLine(pos.row);
- var prefix = util.retrievePrecedingIdentifier(line, pos.column);
+ var prefix = util.getCompletionPrefix(editor);
this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
this.base.$insertRight = true;
var matches = [];
var total = editor.completers.length;
editor.completers.forEach(function(completer, i) {
completer.getCompletions(editor, session, pos, prefix, function(err, results) {
- if (!err)
+ if (!err && results)
matches = matches.concat(results);
var pos = editor.getCursorPosition();
var line = session.getLine(pos.row);
callback(null, {
- prefix: util.retrievePrecedingIdentifier(line, pos.column, results[0] && results[0].identifierRegex),
+ prefix: prefix,
matches: matches,
finished: (--total === 0)
});
});
});
@@ -1803,11 +1818,12 @@
}
};
var completers = [snippetCompleter, textCompleter, keyWordCompleter];
exports.setCompleters = function(val) {
- completers = val || [];
+ completers.length = 0;
+ if (val) completers.push.apply(completers, val);
};
exports.addCompleter = function(completer) {
completers.push(completer);
};
exports.textCompleter = textCompleter;
@@ -1854,33 +1870,18 @@
}
}
});
};
-function getCompletionPrefix(editor) {
- var pos = editor.getCursorPosition();
- var line = editor.session.getLine(pos.row);
- var prefix;
- editor.completers.forEach(function(completer) {
- if (completer.identifierRegexps) {
- completer.identifierRegexps.forEach(function(identifierRegex) {
- if (!prefix && identifierRegex)
- prefix = util.retrievePrecedingIdentifier(line, pos.column, identifierRegex);
- });
- }
- });
- return prefix || util.retrievePrecedingIdentifier(line, pos.column);
-}
-
var doLiveAutocomplete = function(e) {
var editor = e.editor;
var hasCompleter = editor.completer && editor.completer.activated;
if (e.command.name === "backspace") {
- if (hasCompleter && !getCompletionPrefix(editor))
+ if (hasCompleter && !util.getCompletionPrefix(editor))
editor.completer.detach();
}
else if (e.command.name === "insertstring") {
- var prefix = getCompletionPrefix(editor);
+ var prefix = util.getCompletionPrefix(editor);
if (prefix && !hasCompleter) {
if (!editor.completer) {
editor.completer = new Autocomplete();
}
editor.completer.autoInsert = false;
\ No newline at end of file