Merge pull request #2309 from ajaxorg/misc

Fix several small issues
This commit is contained in:
Lennart Kats 2015-01-13 09:54:25 +01:00
commit d62315a740
24 changed files with 2198 additions and 807 deletions

View file

@ -20,7 +20,7 @@ class Range
end
end
{:id => 34, :key => "value"}
{:id => ?", :key => "value"}
herDocs = [<<'FOO', <<BAR, <<-BAZ, <<-`EXEC`] #comment

View file

@ -53,16 +53,16 @@ require("ace/commands/default_commands").commands.push({
return;
}
var rowCount = 10;
var rowCount = 10;
var w = {
row: row,
// rowCount: rowCount,
fixedWidth: true,
el: dom.createElement("div"),
editor: editor
editor: inlineEditor
};
var el = w.el;
el.appendChild(inlineEditor.container);
el.appendChild(inlineEditor.container);
if (!editor.session.widgetManager) {
editor.session.widgetManager = new LineWidgets(editor.session);

View file

@ -40,9 +40,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);
@ -59,7 +60,6 @@ var Autocomplete = function() {
};
(function() {
this.gatherCompletionsId = 0;
this.$init = function() {
this.popup = new AcePopup(document.body || document.documentElement);
@ -84,6 +84,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) {
@ -115,10 +117,9 @@ 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();
@ -261,7 +262,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);
@ -408,10 +408,10 @@ 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);
// needed for firefox on mac
// prevent ctrl-space opening context menu on firefox on mac
editor.completer.cancelContextMenu();
},
bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space"

View file

@ -545,9 +545,12 @@ var Editor = function(renderer, session) {
return;
}
if (token.type.indexOf("tag-open") != -1)
if (token.type.indexOf("tag-open") != -1) {
token = iterator.stepForward();
if (!token)
return;
}
var tag = token.value;
var depth = 0;
var prevToken = iterator.stepBackward();

View file

@ -140,7 +140,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;
// Try to find custom prefixes on the completers
editor.completers.forEach(function(completer) {
if (completer.identifierRegexps) {
@ -150,7 +150,7 @@ function getCompletionPrefix(editor) {
});
}
});
return prefix;
return prefix || util.retrievePrecedingIdentifier(line, pos.column);
}
var doLiveAutocomplete = function(e) {
@ -158,8 +158,6 @@ var doLiveAutocomplete = function(e) {
var text = e.args || "";
var hasCompleter = editor.completer && editor.completer.activated;
// We don't want to autocomplete with no prefix
if (e.command.name === "backspace") {
if (hasCompleter && !getCompletionPrefix(editor))
@ -174,7 +172,6 @@ var doLiveAutocomplete = function(e) {
editor.completer = new Autocomplete();
}
// Disable autoInsert
editor.completer.autoSelect = false;
editor.completer.autoInsert = false;
editor.completer.showPopup(editor);
}

View file

@ -13,7 +13,7 @@
[1, +1, -1, 12_345, 0.000_1,
_, 3_1, 1_2, 1_.0, 0._1];
{:id => 34, :key => "value"}
{:id => ?", :key => "value", anotherKey: [x, y?]}
=begin
=end

View file

@ -139,7 +139,7 @@
["text"," "],
["punctuation.separator.key-value","=>"],
["text"," "],
["constant.numeric","34"],
["string.character","?\""],
["text",", "],
["constant.other.symbol.ruby",":key"],
["text"," "],
@ -148,7 +148,15 @@
["string.start","\""],
["string","value"],
["string.end","\""],
["paren.rparen","}"]
["text",", "],
["identifier","anotherKey"],
["text",": "],
["paren.lparen","["],
["identifier","x"],
["text",", "],
["identifier","y"],
["text","?"],
["paren.rparen","]}"]
],[
"start"
],[

View file

@ -116,11 +116,11 @@ oop.inherits(Mode, TextMode);
var worker = new WorkerClient(["ace"], "ace/mode/coffee_worker", "Worker");
worker.attachToDocument(session.getDocument());
worker.on("error", function(e) {
session.setAnnotations([e.data]);
worker.on("annotate", function(e) {
session.setAnnotations(e.data);
});
worker.on("ok", function(e) {
worker.on("terminate", function() {
session.clearAnnotations();
});

View file

@ -49,13 +49,13 @@ oop.inherits(Worker, Mirror);
this.onUpdate = function() {
var value = this.doc.getValue();
var errors = [];
try {
coffee.parse(value).compile();
} catch(e) {
var loc = e.location;
if (loc) {
this.sender.emit("error", {
errors.push({
row: loc.first_line,
column: loc.first_column,
endRow: loc.last_line,
@ -64,9 +64,8 @@ oop.inherits(Worker, Mirror);
type: "error"
});
}
return;
}
this.sender.emit("ok");
this.sender.emit("annotate", errors);
};
}).call(Worker.prototype);

View file

@ -81,7 +81,7 @@ oop.inherits(Mode, TextMode);
var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
worker.attachToDocument(session.getDocument());
worker.on("csslint", function(e) {
worker.on("annotate", function(e) {
session.setAnnotations(e.data);
});

View file

@ -80,11 +80,11 @@ oop.inherits(Worker, Mirror);
this.onUpdate = function() {
var value = this.doc.getValue();
if (!value)
return this.sender.emit("csslint", []);
return this.sender.emit("annotate", []);
var infoRules = this.infoRules;
var result = CSSLint.verify(value, this.ruleset);
this.sender.emit("csslint", result.messages.map(function(msg) {
this.sender.emit("annotate", result.messages.map(function(msg) {
return {
row: msg.line - 1,
column: msg.col - 1,

View file

@ -98,7 +98,7 @@ oop.inherits(Mode, TextMode);
var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
worker.attachToDocument(session.getDocument());
worker.on("jslint", function(results) {
worker.on("annotate", function(results) {
session.setAnnotations(results.data);
});

File diff suppressed because it is too large Load diff

View file

@ -116,12 +116,10 @@ oop.inherits(JavaScriptWorker, Mirror);
this.onUpdate = function() {
var value = this.doc.getValue();
value = value.replace(/^#!.*\n/, "\n");
if (!value) {
this.sender.emit("jslint", []);
return;
}
var errors = [];
if (!value)
return this.sender.emit("annotate", []);
var errors = [];
// jshint reports many false errors
// report them as error only if code is actually invalid
var maxErrorLevel = this.isValidJS(value) ? "warning" : "error";
@ -179,7 +177,7 @@ oop.inherits(JavaScriptWorker, Mirror);
}
// console.log("lint time: " + (new Date() - start));
this.sender.emit("jslint", errors);
this.sender.emit("annotate", errors);
};
}).call(JavaScriptWorker.prototype);

View file

@ -74,11 +74,11 @@ oop.inherits(Mode, TextMode);
var worker = new WorkerClient(["ace"], "ace/mode/json_worker", "JsonWorker");
worker.attachToDocument(session.getDocument());
worker.on("error", function(e) {
session.setAnnotations([e.data]);
worker.on("annotate", function(e) {
session.setAnnotations(e.data);
});
worker.on("ok", function() {
worker.on("terminate", function() {
session.clearAnnotations();
});

View file

@ -46,21 +46,20 @@ oop.inherits(JsonWorker, Mirror);
this.onUpdate = function() {
var value = this.doc.getValue();
var errors = [];
try {
if (value)
parse(value);
} catch (e) {
var pos = this.doc.indexToPosition(e.at-1);
this.sender.emit("error", {
errors.push({
row: pos.row,
column: pos.column,
text: e.message,
type: "error"
});
return;
}
this.sender.emit("ok");
this.sender.emit("annotate", errors);
};
}).call(JsonWorker.prototype);

View file

@ -58,7 +58,7 @@ module.exports = {
worker.setValue("{}");
worker.deferredUpdate.call();
assert.equal(this.sender.events[0][0], "ok");
assert.equal(this.sender.events[0][1].length, 0);
},
"test check for syntax error": function() {
@ -71,11 +71,12 @@ module.exports = {
worker.deferredUpdate.call();
var event = this.sender.events[0];
assert.equal(event[0], "error");
assert.equal(event[1].type, "error");
assert.equal(event[1].text, "Bad string");
assert.equal(event[1].row, 1);
assert.equal(event[1].column, 0);
assert.equal(event[0], "annotate");
assert.equal(event[1].length, 1);
assert.equal(event[1][0].type, "error");
assert.equal(event[1][0].text, "Bad string");
assert.equal(event[1][0].row, 1);
assert.equal(event[1][0].column, 0);
},
@ -85,11 +86,11 @@ module.exports = {
worker.deferredUpdate.call();
var event = this.sender.events[0];
assert.equal(event[0], "error");
assert.equal(event[1].type, "error");
assert.equal(event[1].text, "Unexpected 'x'");
assert.equal(event[1].row, 0);
assert.equal(event[1].column, 0);
assert.equal(event[0], "annotate");
assert.equal(event[1][0].type, "error");
assert.equal(event[1][0].text, "Unexpected 'x'");
assert.equal(event[1][0].row, 0);
assert.equal(event[1][0].column, 0);
}
};

View file

@ -52,8 +52,7 @@ define(function(require, exports, module){
}(require('../mode/text').Mode));
keywordend = '(?![$\\w]|-[A-Za-z]|\\s*:(?![:=]))';
stringfill = {
token: 'string',
regex: '.+'
defaultToken: 'string'
};
LiveScriptMode.Rules = {
start: [
@ -146,7 +145,7 @@ define(function(require, exports, module){
next: 'key'
}, {
token: 'keyword.operator',
regex: '\\S+'
regex: '[\\^!|&%+\\-]+'
}, {
token: 'text',
regex: '\\s+'
@ -164,8 +163,7 @@ define(function(require, exports, module){
token: 'comment.regex',
regex: '\\s+(?:#.*)?'
}, {
token: 'string.regex',
regex: '\\S+'
defaultToken: 'string.regex'
}
],
key: [
@ -178,7 +176,7 @@ define(function(require, exports, module){
next: 'start'
}, {
token: 'text',
regex: '.',
regex: '',
next: 'start'
}
],
@ -188,8 +186,7 @@ define(function(require, exports, module){
regex: '.*?\\*/',
next: 'start'
}, {
token: 'comment.doc',
regex: '.+'
defaultToken: 'comment.doc'
}
],
qdoc: [

View file

@ -148,11 +148,11 @@ oop.inherits(Mode, TextMode);
var worker = new WorkerClient(["ace"], "ace/mode/lua_worker", "Worker");
worker.attachToDocument(session.getDocument());
worker.on("error", function(e) {
session.setAnnotations([e.data]);
worker.on("annotate", function(e) {
session.setAnnotations(e.data);
});
worker.on("ok", function(e) {
worker.on("terminate", function() {
session.clearAnnotations();
});

View file

@ -46,24 +46,23 @@ oop.inherits(Worker, Mirror);
this.onUpdate = function() {
var value = this.doc.getValue();
// var t=Date.now()
var errors = [];
// var t=Date.now()
try {
luaparse.parse(value);
} catch(e) {
if (e instanceof SyntaxError) {
this.sender.emit("error", {
row: e.line - 1,
column: e.column,
text: e.message,
type: "error"
});
errors.push({
row: e.line - 1,
column: e.column,
text: e.message,
type: "error"
});
}
// console.log( t-Date.now())
return;
}
// console.log( t-Date.now())
this.sender.emit("ok");
// console.log( t-Date.now())
this.sender.emit("annotate", errors);
};
}).call(Worker.prototype);

View file

@ -143,11 +143,11 @@ oop.inherits(Mode, HtmlMode);
if (this.inlinePhp)
worker.call("setOptions", [{inline: true}]);
worker.on("error", function(e) {
worker.on("annotate", function(e) {
session.setAnnotations(e.data);
});
worker.on("ok", function() {
worker.on("terminate", function() {
session.clearAnnotations();
});

View file

@ -69,11 +69,7 @@ oop.inherits(PhpWorker, Mirror);
// console.log("lint time: " + (new Date() - start));
if (errors.length) {
this.sender.emit("error", errors);
} else {
this.sender.emit("ok");
}
this.sender.emit("annotate", errors);
};
}).call(PhpWorker.prototype);

View file

@ -288,6 +288,9 @@ var RubyHighlightRules = function() {
return stack[0];
return currentState;
}
}, {
token : "string.character",
regex : "\\B\\?."
}, {
token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"

View file

@ -135,6 +135,10 @@ var deps = {
});
}
},
liveScript: {
path: "mode/livescript.js",
url: "https://raw.githubusercontent.com/gkz/LiveScript/master/lib/mode-ls.js"
},
coffee: {
fetch: function(){
var rootHref = "https://raw.github.com/jashkenas/coffee-script/master/";