vendor/assets/javascripts/ace/ext-language_tools.js in ace-rails-ap-4.1.2 vs vendor/assets/javascripts/ace/ext-language_tools.js in ace-rails-ap-4.1.3
- old
+ new
@@ -1089,10 +1089,11 @@
};
popup.$blockScrolling = Infinity;
popup.isOpen = false;
popup.isTopdown = false;
+ popup.autoSelect = true;
popup.data = [];
popup.setData = function(list) {
popup.setValue(lang.stringRepeat("\n", list.length), -1);
popup.data = list || [];
@@ -1104,11 +1105,11 @@
popup.getRow = function() {
return selectionMarker.start.row;
};
popup.setRow = function(line) {
- line = Math.max(0, Math.min(this.data.length, line));
+ line = Math.max(this.autoSelect ? 0 : -1, 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);
@@ -1331,10 +1332,12 @@
this.openPopup = function(editor, prefix, keepPopupPosition) {
if (!this.popup)
this.$init();
+ this.popup.autoSelect = this.autoSelect;
+
this.popup.setData(this.completions.filtered);
editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
var renderer = editor.renderer;
@@ -1388,16 +1391,13 @@
else
this.detach();
};
this.blurListener = function(e) {
- if (e.relatedTarget && e.relatedTarget.nodeName == "A" && e.relatedTarget.href) {
- window.open(e.relatedTarget.href, "_blank");
- }
var el = document.activeElement;
var text = this.editor.textInput.getElement();
- var fromTooltip = e.relatedTarget && e.relatedTarget == this.tooltipNode;
+ var fromTooltip = e.relatedTarget && this.tooltipNode && this.tooltipNode.contains(e.relatedTarget);
var container = this.popup && this.popup.container;
if (el != text && el.parentNode != container && !fromTooltip
&& el != this.tooltipNode && e.relatedTarget != text
) {
this.detach();
@@ -1474,11 +1474,10 @@
this.gatherCompletions = function(editor, callback) {
var session = editor.getSession();
var pos = editor.getCursorPosition();
- var line = session.getLine(pos.row);
var prefix = util.getCompletionPrefix(editor);
this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
this.base.$insertRight = true;
@@ -1486,14 +1485,12 @@
var total = editor.completers.length;
editor.completers.forEach(function(completer, i) {
completer.getCompletions(editor, session, pos, prefix, function(err, results) {
if (!err && results)
matches = matches.concat(results);
- var pos = editor.getCursorPosition();
- var line = session.getLine(pos.row);
callback(null, {
- prefix: prefix,
+ prefix: util.getCompletionPrefix(editor),
matches: matches,
finished: (--total === 0)
});
});
});
@@ -1602,10 +1599,11 @@
this.tooltipNode.className = "ace_tooltip ace_doc-tooltip";
this.tooltipNode.style.margin = 0;
this.tooltipNode.style.pointerEvents = "auto";
this.tooltipNode.tabIndex = -1;
this.tooltipNode.onblur = this.blurListener.bind(this);
+ this.tooltipNode.onclick = this.onTooltipClick.bind(this);
}
var tooltipNode = this.tooltipNode;
if (item.docHTML) {
tooltipNode.innerHTML = item.docHTML;
@@ -1638,9 +1636,21 @@
this.editor.focus();
this.tooltipNode = null;
if (el.parentNode)
el.parentNode.removeChild(el);
};
+
+ this.onTooltipClick = function(e) {
+ var a = e.target;
+ while (a && a != this.tooltipNode) {
+ if (a.nodeName == "A" && a.href) {
+ a.rel = "noreferrer";
+ a.target = "_blank";
+ break;
+ }
+ a = a.parentNode;
+ }
+ }
}).call(Autocomplete.prototype);
Autocomplete.startCommand = {
name: "startAutocomplete",
\ No newline at end of file