Merge pull request #2137 from ajaxorg/autocomplete
Fix several small issues
This commit is contained in:
commit
e894b5f9e0
9 changed files with 122 additions and 24 deletions
|
|
@ -1 +1,17 @@
|
||||||
TODO
|
%{
|
||||||
|
%{
|
||||||
|
Ace Matlab demo
|
||||||
|
%}
|
||||||
|
%}
|
||||||
|
|
||||||
|
classdef hello
|
||||||
|
methods
|
||||||
|
function greet(this)
|
||||||
|
disp('Hello!') % say hi
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
% transpose
|
||||||
|
a = [ 'x''y', "x\n\
|
||||||
|
y", 1' ]' + 2'
|
||||||
|
|
@ -47,3 +47,9 @@ body {
|
||||||
right: 0;
|
right: 0;
|
||||||
border-left: 1px solid;
|
border-left: 1px solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* .ace_text-input {
|
||||||
|
z-index: 10!important;
|
||||||
|
opacity: 1!important;
|
||||||
|
background: rgb(84, 0, 255)!important;
|
||||||
|
}*/
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,11 @@ function highlight() {
|
||||||
var highlighter = ace.require("ace/ext/static_highlight")
|
var highlighter = ace.require("ace/ext/static_highlight")
|
||||||
var dom = ace.require("ace/lib/dom")
|
var dom = ace.require("ace/lib/dom")
|
||||||
function qsa(sel) {
|
function qsa(sel) {
|
||||||
return Array.apply(null, document.querySelectorAll(sel));
|
var els = document.querySelectorAll(sel);
|
||||||
|
var result = [];
|
||||||
|
for (var i = 0, l = els.length; i < l; i++)
|
||||||
|
result[i] = els[i];
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
qsa("code[class]").forEach(function(el) {
|
qsa("code[class]").forEach(function(el) {
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,8 @@ var Autocomplete = function() {
|
||||||
pos.left += renderer.$gutterLayer.gutterWidth;
|
pos.left += renderer.$gutterLayer.gutterWidth;
|
||||||
|
|
||||||
this.popup.show(pos, lineHeight);
|
this.popup.show(pos, lineHeight);
|
||||||
|
} else if (keepPopupPosition && !prefix) {
|
||||||
|
this.detach();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -206,6 +208,7 @@ var Autocomplete = function() {
|
||||||
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
|
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
|
||||||
|
|
||||||
this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
|
this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
|
||||||
|
this.base.$insertRight = true;
|
||||||
|
|
||||||
var matches = [];
|
var matches = [];
|
||||||
var total = editor.completers.length;
|
var total = editor.completers.length;
|
||||||
|
|
@ -297,7 +300,7 @@ var Autocomplete = function() {
|
||||||
return detachIfFinished();
|
return detachIfFinished();
|
||||||
|
|
||||||
// Autoinsert if one result
|
// Autoinsert if one result
|
||||||
if (this.autoInsert && filtered.length == 1)
|
if (this.autoInsert && filtered.length == 1 && results.finished)
|
||||||
return this.insertMatch(filtered[0]);
|
return this.insertMatch(filtered[0]);
|
||||||
|
|
||||||
this.openPopup(this.editor, prefix, keepPopupPosition);
|
this.openPopup(this.editor, prefix, keepPopupPosition);
|
||||||
|
|
|
||||||
|
|
@ -969,8 +969,10 @@ var EditSession = function(text, mode) {
|
||||||
try {
|
try {
|
||||||
this.$worker = this.$mode.createWorker(this);
|
this.$worker = this.$mode.createWorker(this);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if (typeof console == "object") {
|
||||||
console.log("Could not load worker");
|
console.log("Could not load worker");
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
}
|
||||||
this.$worker = null;
|
this.$worker = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -1958,6 +1960,8 @@ var EditSession = function(text, mode) {
|
||||||
split = lastSplit + wrapLimit;
|
split = lastSplit + wrapLimit;
|
||||||
// The split is inside of a CHAR or CHAR_EXT token and no space
|
// The split is inside of a CHAR or CHAR_EXT token and no space
|
||||||
// around -> force a split.
|
// around -> force a split.
|
||||||
|
if (tokens[split] == CHAR_EXT)
|
||||||
|
split--;
|
||||||
addSplit(split);
|
addSplit(split);
|
||||||
}
|
}
|
||||||
return splits;
|
return splits;
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ var TextInput = function(parentNode, host) {
|
||||||
text.spellcheck = false;
|
text.spellcheck = false;
|
||||||
|
|
||||||
text.style.opacity = "0";
|
text.style.opacity = "0";
|
||||||
|
if (useragent.isOldIE) text.style.top = "-100px";
|
||||||
parentNode.insertBefore(text, parentNode.firstChild);
|
parentNode.insertBefore(text, parentNode.firstChild);
|
||||||
|
|
||||||
var PLACEHOLDER = "\x01\x01";
|
var PLACEHOLDER = "\x01\x01";
|
||||||
|
|
@ -436,6 +437,8 @@ var TextInput = function(parentNode, host) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.moveToMouse = function(e, bringToFront) {
|
this.moveToMouse = function(e, bringToFront) {
|
||||||
|
if (!bringToFront && useragent.isOldIE)
|
||||||
|
return;
|
||||||
if (!tempStyle)
|
if (!tempStyle)
|
||||||
tempStyle = text.style.cssText;
|
tempStyle = text.style.cssText;
|
||||||
text.style.cssText = (bringToFront ? "z-index:100000;" : "")
|
text.style.cssText = (bringToFront ? "z-index:100000;" : "")
|
||||||
|
|
@ -460,13 +463,15 @@ var TextInput = function(parentNode, host) {
|
||||||
host.renderer.$keepTextAreaAtCursor = null;
|
host.renderer.$keepTextAreaAtCursor = null;
|
||||||
|
|
||||||
// on windows context menu is opened after mouseup
|
// on windows context menu is opened after mouseup
|
||||||
if (useragent.isWin)
|
if (useragent.isWin && !useragent.isOldIE)
|
||||||
event.capture(host.container, move, onContextMenuClose);
|
event.capture(host.container, move, onContextMenuClose);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onContextMenuClose = onContextMenuClose;
|
this.onContextMenuClose = onContextMenuClose;
|
||||||
|
var closeTimeout;
|
||||||
function onContextMenuClose() {
|
function onContextMenuClose() {
|
||||||
setTimeout(function () {
|
clearTimeout(closeTimeout)
|
||||||
|
closeTimeout = setTimeout(function () {
|
||||||
if (tempStyle) {
|
if (tempStyle) {
|
||||||
text.style.cssText = tempStyle;
|
text.style.cssText = tempStyle;
|
||||||
tempStyle = '';
|
tempStyle = '';
|
||||||
|
|
@ -475,7 +480,7 @@ var TextInput = function(parentNode, host) {
|
||||||
host.renderer.$keepTextAreaAtCursor = true;
|
host.renderer.$keepTextAreaAtCursor = true;
|
||||||
host.renderer.$moveTextAreaToCursor();
|
host.renderer.$moveTextAreaToCursor();
|
||||||
}
|
}
|
||||||
}, 0);
|
}, useragent.isOldIE ? 200 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
var onContextMenu = function(e) {
|
var onContextMenu = function(e) {
|
||||||
|
|
|
||||||
|
|
@ -322,7 +322,7 @@ var Text = function(parentEl) {
|
||||||
|
|
||||||
this.$renderToken = function(stringBuilder, screenColumn, token, value) {
|
this.$renderToken = function(stringBuilder, screenColumn, token, value) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g;
|
var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g;
|
||||||
var replaceFunc = function(c, a, b, tabIdx, idx4) {
|
var replaceFunc = function(c, a, b, tabIdx, idx4) {
|
||||||
if (a) {
|
if (a) {
|
||||||
return self.showInvisibles ?
|
return self.showInvisibles ?
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ For more information about SproutCore, visit http://www.sproutcore.com
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
require("./fixoldbrowsers");
|
||||||
|
|
||||||
var oop = require("./oop");
|
var oop = require("./oop");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -164,15 +164,53 @@ var keywords = (
|
||||||
}, "identifier", true);
|
}, "identifier", true);
|
||||||
|
|
||||||
this.$rules = {
|
this.$rules = {
|
||||||
"start" : [ {
|
// allowQstring
|
||||||
|
start: [{
|
||||||
|
token : "string",
|
||||||
|
regex : "'",
|
||||||
|
stateName : "qstring",
|
||||||
|
next : [{
|
||||||
|
token : "constant.language.escape",
|
||||||
|
regex : "''"
|
||||||
|
}, {
|
||||||
|
token : "string",
|
||||||
|
regex : "'|$",
|
||||||
|
next : "start"
|
||||||
|
}, {
|
||||||
|
defaultToken: "string"
|
||||||
|
}]
|
||||||
|
}, {
|
||||||
|
token : "text",
|
||||||
|
regex : "\\s+"
|
||||||
|
}, {
|
||||||
|
regex: "",
|
||||||
|
next: "noQstring"
|
||||||
|
}],
|
||||||
|
noQstring : [{
|
||||||
|
regex: "^\\s*%{\\s*$",
|
||||||
|
token: "comment.start",
|
||||||
|
push: "blockComment"
|
||||||
|
}, {
|
||||||
token : "comment",
|
token : "comment",
|
||||||
regex : "%[^\r\n]*"
|
regex : "%[^\r\n]*"
|
||||||
}, {
|
}, {
|
||||||
token : "string", // " string
|
token : "string",
|
||||||
regex : '".*?"'
|
regex : '"',
|
||||||
|
stateName : "qqstring",
|
||||||
|
next : [{
|
||||||
|
token : "constant.language.escape",
|
||||||
|
regex : /\\./
|
||||||
}, {
|
}, {
|
||||||
token : "string", // ' string
|
token : "string",
|
||||||
regex : "'.*?'"
|
regex : "\\\\$",
|
||||||
|
next : "qqstring"
|
||||||
|
}, {
|
||||||
|
token : "string",
|
||||||
|
regex : '"|$',
|
||||||
|
next : "start"
|
||||||
|
}, {
|
||||||
|
defaultToken: "string"
|
||||||
|
}]
|
||||||
}, {
|
}, {
|
||||||
token : "constant.numeric", // float
|
token : "constant.numeric", // float
|
||||||
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||||
|
|
@ -181,21 +219,41 @@ var keywords = (
|
||||||
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||||
}, {
|
}, {
|
||||||
token : "keyword.operator",
|
token : "keyword.operator",
|
||||||
regex : "\\+|\\-|\\/|\\/\\/|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
|
regex : "\\+|\\-|\\/|\\/\\/|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=",
|
||||||
|
next: "start"
|
||||||
}, {
|
}, {
|
||||||
token : "punctuation.operator",
|
token : "punctuation.operator",
|
||||||
regex : "\\?|\\:|\\,|\\;|\\."
|
regex : "\\?|\\:|\\,|\\;|\\.",
|
||||||
|
next: "start"
|
||||||
}, {
|
}, {
|
||||||
token : "paren.lparen",
|
token : "paren.lparen",
|
||||||
regex : "[\\(]"
|
regex : "[({\\[]",
|
||||||
|
next: "start"
|
||||||
}, {
|
}, {
|
||||||
token : "paren.rparen",
|
token : "paren.rparen",
|
||||||
regex : "[\\)]"
|
regex : "[\\]})]"
|
||||||
}, {
|
}, {
|
||||||
token : "text",
|
token : "text",
|
||||||
regex : "\\s+"
|
regex : "\\s+"
|
||||||
} ]
|
}, {
|
||||||
|
token : "text",
|
||||||
|
regex : "$",
|
||||||
|
next : "start"
|
||||||
|
}],
|
||||||
|
blockComment: [{
|
||||||
|
regex: "^\\s*%{\\s*$",
|
||||||
|
token: "comment.start",
|
||||||
|
push: "blockComment"
|
||||||
|
}, {
|
||||||
|
regex: "^\\s*%}\\s*$",
|
||||||
|
token: "comment.end",
|
||||||
|
next: "pop"
|
||||||
|
}, {
|
||||||
|
defaultToken: "comment"
|
||||||
|
}],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.normalizeRules();
|
||||||
};
|
};
|
||||||
|
|
||||||
oop.inherits(MatlabHighlightRules, TextHighlightRules);
|
oop.inherits(MatlabHighlightRules, TextHighlightRules);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue