diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index 45058913b1c..ff6a01b136b 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -45,6 +45,7 @@ function bindKey(win, mac) { */ exports.commands = [{ name: "showSettingsMenu", + description: "Show settings menu", bindKey: bindKey("Ctrl-,", "Command-,"), exec: function(editor) { config.loadModule("ace/ext/settings_menu", function(module) { @@ -55,6 +56,7 @@ exports.commands = [{ readOnly: true }, { name: "goToNextError", + description: "Go to next error", bindKey: bindKey("Alt-E", "F4"), exec: function(editor) { config.loadModule("./ext/error_marker", function(module) { @@ -65,6 +67,7 @@ exports.commands = [{ readOnly: true }, { name: "goToPreviousError", + description: "Go to previous error", bindKey: bindKey("Alt-Shift-E", "Shift-F4"), exec: function(editor) { config.loadModule("./ext/error_marker", function(module) { @@ -112,6 +115,7 @@ exports.commands = [{ readOnly: true }, { name: "toggleFoldWidget", + description: "Toggle fold widget", bindKey: bindKey("F2", "F2"), exec: function(editor) { editor.session.toggleFoldWidget(); }, multiSelectAction: "forEach", @@ -119,6 +123,7 @@ exports.commands = [{ readOnly: true }, { name: "toggleParentFoldWidget", + description: "Toggle parent fold widget", bindKey: bindKey("Alt-F2", "Alt-F2"), exec: function(editor) { editor.session.toggleFoldWidget(true); }, multiSelectAction: "forEach", @@ -855,6 +860,7 @@ exports.commands = [{ scrollIntoView: "none" }, { name: "addLineAfter", + description: "Add new line after the current line", exec: function(editor) { editor.selection.clearSelection(); editor.navigateLineEnd(); @@ -864,6 +870,7 @@ exports.commands = [{ scrollIntoView: "cursor" }, { name: "addLineBefore", + description: "Add new line before the current line", exec: function(editor) { editor.selection.clearSelection(); var cursor = editor.getCursorPosition(); diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 3e48a10bab0..72f10444af2 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -183,7 +183,7 @@ EditSession.$uid = 0; **/ this.setDocument = function(doc) { if (this.doc) - this.doc.removeListener("change", this.$onChange); + this.doc.off("change", this.$onChange); this.doc = doc; doc.on("change", this.$onChange); @@ -2404,6 +2404,9 @@ EditSession.$uid = 0; } this.$stopWorker(); this.removeAllListeners(); + if (this.doc) { + this.doc.off("change", this.$onChange); + } this.selection.detach(); }; diff --git a/lib/ace/ext/modelist.js b/lib/ace/ext/modelist.js index e9fa1fb3a5c..cf6a957cc92 100644 --- a/lib/ace/ext/modelist.js +++ b/lib/ace/ext/modelist.js @@ -52,7 +52,7 @@ var supportedModes = { Apex: ["apex|cls|trigger|tgr"], AQL: ["aql"], AsciiDoc: ["asciidoc|adoc"], - ASL: ["dsl|asl"], + ASL: ["dsl|asl|asl.json"], Assembly_x86:["asm|a"], AutoHotKey: ["ahk"], BatchFile: ["bat|cmd"], diff --git a/lib/ace/mouse/mouse_handler.js b/lib/ace/mouse/mouse_handler.js index e6287dd1964..22912d7706a 100644 --- a/lib/ace/mouse/mouse_handler.js +++ b/lib/ace/mouse/mouse_handler.js @@ -101,6 +101,7 @@ var MouseHandler = function(editor) { (function() { this.onMouseEvent = function(name, e) { + if (!this.editor.session) return; this.editor._emit(name, new MouseEvent(e, this.editor)); }; @@ -155,7 +156,7 @@ var MouseHandler = function(editor) { var onCaptureEnd = function(e) { editor.off("beforeEndOperation", onOperationEnd); clearInterval(timerId); - onCaptureInterval(); + if (editor.session) onCaptureInterval(); self[self.state + "End"] && self[self.state + "End"](e); self.state = ""; self.isMousePressed = renderer.$isMousePressed = false; diff --git a/lib/ace/selection.js b/lib/ace/selection.js index 1d8fa5b991e..9b12ce0c34f 100644 --- a/lib/ace/selection.js +++ b/lib/ace/selection.js @@ -840,7 +840,6 @@ var Selection = function(session) { this.detach = function() { this.lead.detach(); this.anchor.detach(); - this.session = this.doc = null; }; this.fromOrientedRange = function(range) { diff --git a/lib/ace/test/mockdom.js b/lib/ace/test/mockdom.js index 9c89ab5a4d1..fd5e4f38f33 100644 --- a/lib/ace/test/mockdom.js +++ b/lib/ace/test/mockdom.js @@ -1,7 +1,6 @@ define(function(require, exports, module) { "use strict"; -var escapeHTML = require("../lib/lang").escapeHTML; var dom = require("../lib/dom"); var CHAR_HEIGHT = 10; @@ -140,7 +139,7 @@ function Node(name) { this.insertBefore(children[j], before); } else { - this.children.splice(i - 1, 0, node); + this.children.splice(i, 0, node); node.nextSibling = this.children[i]; node.previousSibling = this.children[i - 2]; if (node.nextSibling) @@ -451,7 +450,7 @@ function Node(name) { function parseSimpleSelector(selector) { var tests = []; selector.replace( - /([#.])?([\w-]+)|\[\s*([\w-]+)\s*(?:=\s*([\w-]+)\s*)?\]|\*|./g, + /([#.])?([\w-]+)|\[\s*([\w-]+)\s*(?:=\s*"?([\w-]+)"?\s*)?\]|\*|./g, function(_, hash, name, attr, attrValue) { if (hash == "#") { tests.push(function(node) { return node.id == name; }); @@ -490,13 +489,7 @@ function setInnerHTML(markup, parent, strict) { skipped += markup.substring(lastIndex, m.index); var encoded = m[2]; if (encoded) { - if (encoded == "gt") { - skipped += ">"; - } else if (encoded == "lt") { - skipped += "<"; - } else if (encoded == "amp") { - skipped += "&"; - } + skipped += parseCharacterEntity(encoded); lastIndex = tagRe.lastIndex; } else { if (m[1] == "!") { @@ -543,6 +536,21 @@ function setInnerHTML(markup, parent, strict) { if (strict && root != parent) throw new Error("Invalid XML message:"); } +function parseCharacterEntity(encoded) { + if (encoded[0] == "#") { + var charCode = encoded.slice(1); + if (charCode[0] == "x") + return String.fromCharCode(parseInt(charCode.slice(1), 16)); + return String.fromCharCode(parseInt(charCode, 10)); + } + if (encoded == "gt") return ">"; + if (encoded == "lt") return "<"; + if (encoded == "amp") return "&"; + if (encoded == "quot") return '"'; + + console.error("Skipping unsupported character entity", encoded); + return ""; +} function parseDocType(markup, tagRe, strict) { var start = tagRe.lastIndex; var end = -1; @@ -562,6 +570,13 @@ function parseDocType(markup, tagRe, strict) { tagRe.lastIndex = end; return text; } +function escapeHTML(str) { + return str.replace(/[<>&]/g, function(char) { + if (char == "<") return "<"; + if (char == ">") return ">"; + if (char == "&") return "&"; + }); +} function Event(type, options) { this.type = type;