Skip to content

Commit

Permalink
Merge pull request #4502 from ajaxorg/c9-sync
Browse files Browse the repository at this point in the history
sync with c9
  • Loading branch information
nightwing committed May 31, 2021
2 parents 9992db9 + 6ce92b4 commit 145328b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 14 deletions.
7 changes: 7 additions & 0 deletions lib/ace/commands/default_commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -112,13 +115,15 @@ exports.commands = [{
readOnly: true
}, {
name: "toggleFoldWidget",
description: "Toggle fold widget",
bindKey: bindKey("F2", "F2"),
exec: function(editor) { editor.session.toggleFoldWidget(); },
multiSelectAction: "forEach",
scrollIntoView: "center",
readOnly: true
}, {
name: "toggleParentFoldWidget",
description: "Toggle parent fold widget",
bindKey: bindKey("Alt-F2", "Alt-F2"),
exec: function(editor) { editor.session.toggleFoldWidget(true); },
multiSelectAction: "forEach",
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion lib/ace/edit_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -2404,6 +2404,9 @@ EditSession.$uid = 0;
}
this.$stopWorker();
this.removeAllListeners();
if (this.doc) {
this.doc.off("change", this.$onChange);
}
this.selection.detach();
};

Expand Down
2 changes: 1 addition & 1 deletion lib/ace/ext/modelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
3 changes: 2 additions & 1 deletion lib/ace/mouse/mouse_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};

Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion lib/ace/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
35 changes: 25 additions & 10 deletions lib/ace/test/mockdom.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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; });
Expand Down Expand Up @@ -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] == "!") {
Expand Down Expand Up @@ -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;
Expand All @@ -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 "&lt;";
if (char == ">") return "&gt;";
if (char == "&") return "&amp;";
});
}

function Event(type, options) {
this.type = type;
Expand Down

0 comments on commit 145328b

Please sign in to comment.