Skip to content

Commit

Permalink
Bump ace to v1.1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
gkop committed Jun 5, 2015
1 parent d1af87c commit 7278000
Show file tree
Hide file tree
Showing 124 changed files with 25,999 additions and 14,590 deletions.
729 changes: 403 additions & 326 deletions vendor/assets/javascripts/ace/ace.js

Large diffs are not rendered by default.

96 changes: 56 additions & 40 deletions vendor/assets/javascripts/ace/ext-language_tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,11 @@ var AcePopup = function(parentNode) {

if (data.meta) {
var maxW = popup.renderer.$size.scrollerWidth / popup.renderer.layerConfig.characterWidth;
if (data.meta.length + data.caption.length < maxW - 2)
tokens.push({type: "rightAlignedText", value: data.meta});
var metaData = data.meta;
if (metaData.length + data.caption.length > maxW - 2) {
metaData = metaData.substr(0, maxW - data.caption.length - 3) + "\u2026"
}
tokens.push({type: "rightAlignedText", value: metaData});
}
return tokens;
};
Expand All @@ -1080,6 +1083,8 @@ var AcePopup = function(parentNode) {
popup.session.$computeWidth = function() {
return this.screenWidth = 0;
};

popup.$blockScrolling = Infinity;
popup.isOpen = false;
popup.isTopdown = false;

Expand Down Expand Up @@ -1111,6 +1116,7 @@ var AcePopup = function(parentNode) {
popup.on("changeSelection", function() {
if (popup.isOpen)
popup.setRow(popup.selection.lead.row);
popup.renderer.scrollCursorIntoView();
});

popup.hide = function() {
Expand Down Expand Up @@ -1263,8 +1269,10 @@ var dom = require("./lib/dom");
var snippetManager = require("./snippets").snippetManager;

var Autocomplete = function() {
this.autoInsert = true;
this.autoInsert = false;
this.autoSelect = true;
this.exactMatch = false;
this.gatherCompletionsId = 0;
this.keyboardHandler = new HashHandler();
this.keyboardHandler.bindKeys(this.commands);

Expand All @@ -1276,12 +1284,11 @@ var Autocomplete = function() {
this.changeTimer = lang.delayedCall(function() {
this.updateCompletions(true);
}.bind(this));

this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50);
};

(function() {
this.gatherCompletionsId = 0;

this.$init = function() {
this.popup = new AcePopup(document.body || document.documentElement);
Expand All @@ -1295,7 +1302,7 @@ var Autocomplete = function() {
this.popup.on("changeHoverMarker", this.tooltipTimer.bind(null, null));
return this.popup;
};

this.getPopup = function() {
return this.popup || this.$init();
};
Expand All @@ -1306,6 +1313,8 @@ var Autocomplete = function() {

this.popup.setData(this.completions.filtered);

editor.keyBinding.addKeyboardHandler(this.keyboardHandler);

var renderer = editor.renderer;
this.popup.setRow(this.autoSelect ? 0 : -1);
if (!keepPopupPosition) {
Expand Down Expand Up @@ -1337,11 +1346,10 @@ var Autocomplete = function() {
this.changeTimer.cancel();
this.hideDocTooltip();

if (this.popup && this.popup.isOpen) {
this.gatherCompletionsId += 1;
this.gatherCompletionsId += 1;
if (this.popup && this.popup.isOpen)
this.popup.hide();
}


if (this.base)
this.base.detach();
this.activated = false;
Expand All @@ -1362,7 +1370,7 @@ var Autocomplete = function() {
this.blurListener = function(e) {
var el = document.activeElement;
var text = this.editor.textInput.getElement()
if (el != text && el.parentNode != this.popup.container
if (el != text && ( !this.popup || el.parentNode != this.popup.container )
&& el != this.tooltipNode && e.relatedTarget != this.tooltipNode
&& e.relatedTarget != text
) {
Expand Down Expand Up @@ -1424,7 +1432,6 @@ var Autocomplete = function() {
"Ctrl-Down|Ctrl-End": function(editor) { editor.completer.goTo("end"); },

"Esc": function(editor) { editor.completer.detach(); },
"Space": function(editor) { editor.completer.detach(); editor.insert(" ");},
"Return": function(editor) { return editor.completer.insertMatch(); },
"Shift-Return": function(editor) { editor.completer.insertMatch(true); },
"Tab": function(editor) {
Expand All @@ -1448,7 +1455,7 @@ var Autocomplete = function() {

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) {
Expand Down Expand Up @@ -1480,7 +1487,6 @@ var Autocomplete = function() {
editor.completer = this;
}

editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
editor.on("changeSelection", this.changeListener);
editor.on("blur", this.blurListener);
editor.on("mousedown", this.mousedownListener);
Expand Down Expand Up @@ -1514,13 +1520,17 @@ var Autocomplete = function() {

var prefix = results.prefix;
var matches = results && results.matches;

if (!matches || !matches.length)
return detachIfFinished();
if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId)
return;

this.completions = new FilteredList(matches);

if (this.exactMatch)
this.completions.exactMatch = true;

this.completions.setFilter(prefix);
var filtered = this.completions.filtered;
if (!filtered.length)
Expand All @@ -1537,7 +1547,7 @@ var Autocomplete = function() {
this.cancelContextMenu = function() {
this.editor.$mouseHandler.cancelContextMenu();
};

this.updateDocTooltip = function() {
var popup = this.popup;
var all = popup.data;
Expand All @@ -1552,14 +1562,14 @@ var Autocomplete = function() {
});
if (!doc)
doc = selected;

if (typeof doc == "string")
doc = {docText: doc}
if (!doc || !(doc.docHTML || doc.docText))
return this.hideDocTooltip();
this.showDocTooltip(doc);
};

this.showDocTooltip = function(item) {
if (!this.tooltipNode) {
this.tooltipNode = dom.createElement("div");
Expand All @@ -1569,21 +1579,21 @@ var Autocomplete = function() {
this.tooltipNode.tabIndex = -1;
this.tooltipNode.onblur = this.blurListener.bind(this);
}

var tooltipNode = this.tooltipNode;
if (item.docHTML) {
tooltipNode.innerHTML = item.docHTML;
} else if (item.docText) {
tooltipNode.textContent = item.docText;
}

if (!tooltipNode.parentNode)
document.body.appendChild(tooltipNode);
document.body.appendChild(tooltipNode);
var popup = this.popup;
var rect = popup.container.getBoundingClientRect();
tooltipNode.style.top = popup.container.style.top;
tooltipNode.style.bottom = popup.container.style.bottom;

if (window.innerWidth - rect.right < 320) {
tooltipNode.style.right = window.innerWidth - rect.left + "px";
tooltipNode.style.left = "";
Expand All @@ -1593,15 +1603,15 @@ var Autocomplete = function() {
}
tooltipNode.style.display = "block";
};

this.hideDocTooltip = function() {
this.tooltipTimer.cancel();
if (!this.tooltipNode) return;
var el = this.tooltipNode;
if (!this.editor.isFocused() && document.activeElement == el)
this.editor.focus();
this.tooltipNode = null;
if (el.parentNode)
if (el.parentNode)
el.parentNode.removeChild(el);
};

Expand All @@ -1612,7 +1622,7 @@ Autocomplete.startCommand = {
exec: function(editor) {
if (!editor.completer)
editor.completer = new Autocomplete();
editor.completer.autoInsert =
editor.completer.autoInsert = false;
editor.completer.autoSelect = true;
editor.completer.showPopup(editor);
editor.completer.cancelContextMenu();
Expand All @@ -1624,6 +1634,7 @@ var FilteredList = function(array, filterText, mutateData) {
this.all = array;
this.filtered = array;
this.filterText = filterText || "";
this.exactMatch = false;
};
(function(){
this.setFilter = function(str) {
Expand Down Expand Up @@ -1658,20 +1669,26 @@ var FilteredList = function(array, filterText, mutateData) {
var matchMask = 0;
var penalty = 0;
var index, distance;
for (var j = 0; j < needle.length; j++) {
var i1 = caption.indexOf(lower[j], lastIndex + 1);
var i2 = caption.indexOf(upper[j], lastIndex + 1);
index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2;
if (index < 0)

if (this.exactMatch) {
if (needle !== caption.substr(0, needle.length))
continue loop;
distance = index - lastIndex - 1;
if (distance > 0) {
if (lastIndex === -1)
penalty += 10;
penalty += distance;
}else{
for (var j = 0; j < needle.length; j++) {
var i1 = caption.indexOf(lower[j], lastIndex + 1);
var i2 = caption.indexOf(upper[j], lastIndex + 1);
index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2;
if (index < 0)
continue loop;
distance = index - lastIndex - 1;
if (distance > 0) {
if (lastIndex === -1)
penalty += 10;
penalty += distance;
}
matchMask = matchMask | (1 << index);
lastIndex = index;
}
matchMask = matchMask | (1 << index);
lastIndex = index;
}
item.matchMask = matchMask;
item.exactMatch = penalty ? 0 : 1;
Expand Down Expand Up @@ -1839,7 +1856,7 @@ var loadSnippetFile = function(id) {
function getCompletionPrefix(editor) {
var pos = editor.getCursorPosition();
var line = editor.session.getLine(pos.row);
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
var prefix;
editor.completers.forEach(function(completer) {
if (completer.identifierRegexps) {
completer.identifierRegexps.forEach(function(identifierRegex) {
Expand All @@ -1848,7 +1865,7 @@ function getCompletionPrefix(editor) {
});
}
});
return prefix;
return prefix || util.retrievePrecedingIdentifier(line, pos.column);
}

var doLiveAutocomplete = function(e) {
Expand All @@ -1865,7 +1882,6 @@ var doLiveAutocomplete = function(e) {
if (!editor.completer) {
editor.completer = new Autocomplete();
}
editor.completer.autoSelect = false;
editor.completer.autoInsert = false;
editor.completer.showPopup(editor);
}
Expand Down
10 changes: 7 additions & 3 deletions vendor/assets/javascripts/ace/ext-modelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ Mode.prototype.supportsFile = function(filename) {
};
var supportedModes = {
ABAP: ["abap"],
ABC: ["abc"],
ActionScript:["as"],
ADA: ["ada|adb"],
Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
AsciiDoc: ["asciidoc"],
AsciiDoc: ["asciidoc|adoc"],
Assembly_x86:["asm"],
AutoHotKey: ["ahk"],
BatchFile: ["bat|cmd"],
Expand Down Expand Up @@ -90,6 +91,7 @@ var supportedModes = {
JSX: ["jsx"],
Julia: ["jl"],
LaTeX: ["tex|latex|ltx|bib"],
Lean: ["lean|hlean"],
LESS: ["less"],
Liquid: ["liquid"],
Lisp: ["lisp"],
Expand All @@ -101,6 +103,7 @@ var supportedModes = {
Lucene: ["lucene"],
Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
Markdown: ["md|markdown"],
Mask: ["mask"],
MATLAB: ["matlab"],
MEL: ["mel"],
MUSHCode: ["mc|mush"],
Expand Down Expand Up @@ -149,9 +152,10 @@ var supportedModes = {
Velocity: ["vm"],
Verilog: ["v|vh|sv|svh"],
VHDL: ["vhd|vhdl"],
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"],
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
XQuery: ["xq"],
YAML: ["yaml|yml"]
YAML: ["yaml|yml"],
Django: ["html"]
};

var nameOverrides = {
Expand Down
Loading

0 comments on commit 7278000

Please sign in to comment.