Update ACE Editor to version 1.2.9

The new ACE editor introduces full support for emojis (and, thereby, UTF-16 characters with high- and low-surrogates). Hence, we can remove our custom fix.

Further, this update will allow emojis to be used in pair programming sessions.
This commit is contained in:
Sebastian Serth
2023-09-12 18:45:47 +02:00
parent 13bd68d760
commit 60656443e2
210 changed files with 66466 additions and 33266 deletions

View File

@ -18,7 +18,7 @@ oop.inherits(Occur, Search);
var translatedPos = this.originalToOccurPosition(editor.session, pos);
editor.moveCursorToPosition(translatedPos);
return true;
}
};
this.exit = function(editor, options) {
var pos = options.translatePosition && editor.getCursorPosition();
var translatedPos = pos && this.occurToOriginalPosition(editor.session, pos);
@ -26,14 +26,14 @@ oop.inherits(Occur, Search);
if (translatedPos)
editor.moveCursorToPosition(translatedPos);
return true;
}
};
this.highlight = function(sess, regexp) {
var hl = sess.$occurHighlight = sess.$occurHighlight || sess.addDynamicMarker(
new SearchHighlight(null, "ace_occur-highlight", "text"));
hl.setRegexp(regexp);
sess._emit("changeBackMarker"); // force highlight layer redraw
}
};
this.displayOccurContent = function(editor, options) {
this.$originalSession = editor.session;
@ -47,12 +47,12 @@ oop.inherits(Occur, Search);
occurSession.$useEmacsStyleLineStart = this.$useEmacsStyleLineStart;
this.highlight(occurSession, options.re);
occurSession._emit('changeBackMarker');
}
};
this.displayOriginalContent = function(editor) {
editor.setSession(this.$originalSession);
this.$originalSession.$useEmacsStyleLineStart = this.$useEmacsStyleLineStart;
}
};
this.originalToOccurPosition = function(session, pos) {
var lines = session.$occurMatchingLines;
var nullPos = {row: 0, column: 0};
@ -62,13 +62,13 @@ oop.inherits(Occur, Search);
return {row: i, column: pos.column};
}
return nullPos;
}
};
this.occurToOriginalPosition = function(session, pos) {
var lines = session.$occurMatchingLines;
if (!lines || !lines[pos.row])
return pos;
return {row: lines[pos.row].row, column: pos.column};
}
};
this.matchingLines = function(session, options) {
options = oop.mixin({}, options);
@ -82,7 +82,7 @@ oop.inherits(Occur, Search);
lines :
lines.concat({row: row, content: session.getLine(row)});
}, []);
}
};
}).call(Occur.prototype);
@ -151,20 +151,20 @@ function OccurKeyboardHandler() {}
oop.inherits(OccurKeyboardHandler, HashHandler);
;(function() {
(function() {
this.isOccurHandler = true;
this.attach = function(editor) {
HashHandler.call(this, occurCommands, editor.commands.platform);
this.$editor = editor;
}
};
var handleKeyboard$super = this.handleKeyboard;
this.handleKeyboard = function(data, hashId, key, keyCode) {
var cmd = handleKeyboard$super.call(this, data, hashId, key, keyCode);
return (cmd && cmd.command) ? cmd : undefined;
}
};
}).call(OccurKeyboardHandler.prototype);
@ -172,14 +172,14 @@ OccurKeyboardHandler.installIn = function(editor) {
var handler = new this();
editor.keyBinding.addKeyboardHandler(handler);
editor.commands.addCommands(occurCommands);
}
};
OccurKeyboardHandler.uninstallFrom = function(editor) {
editor.commands.removeCommands(occurCommands);
var handler = editor.getKeyboardHandler();
if (handler.isOccurHandler)
editor.keyBinding.removeKeyboardHandler(handler);
}
};
exports.occurStartCommand = occurStartCommand;
@ -328,7 +328,8 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
var iSearch = this.$iSearch;
HashHandler.call(this, exports.iSearchCommands, editor.commands.platform);
this.$commandExecHandler = editor.commands.addEventListener('exec', function(e) {
if (!e.command.isIncrementalSearchCommand) return undefined;
if (!e.command.isIncrementalSearchCommand)
return iSearch.deactivate();
e.stopPropagation();
e.preventDefault();
var scrollTop = editor.session.getScrollTop();
@ -355,7 +356,7 @@ oop.inherits(IncrementalSearchKeyboardHandler, HashHandler);
var extendCmd = this.commands.extendSearchTerm;
if (extendCmd) { return {command: extendCmd, args: key}; }
}
return {command: "null", passEvent: hashId == 0 || hashId == 4};
return false;
};
}).call(IncrementalSearchKeyboardHandler.prototype);
@ -392,7 +393,7 @@ function regExpToObject(re) {
return {
expression: string.slice(start+1, flagStart),
flags: string.slice(flagStart+1)
}
};
}
function stringToRegExp(string, flags) {
@ -405,7 +406,7 @@ function objectToRegExp(obj) {
return stringToRegExp(obj.expression, obj.flags);
}
;(function() {
(function() {
this.activate = function(ed, backwards) {
this.$editor = ed;
@ -613,15 +614,15 @@ var iSearchCommandModule = require("../commands/incremental_search_commands");
var screenToTextBlockCoordinates = function(x, y) {
var canvasPos = this.scroller.getBoundingClientRect();
var offsetX = x + this.scrollLeft - canvasPos.left - this.$padding;
var col = Math.floor(offsetX / this.characterWidth);
var col = Math.floor(
(x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth
);
var row = Math.floor(
(y + this.scrollTop - canvasPos.top) / this.lineHeight
);
return this.session.screenToDocumentPosition(row, col);
return this.session.screenToDocumentPosition(row, col, offsetX);
};
var HashHandler = require("./hash_handler").HashHandler;
@ -711,7 +712,7 @@ exports.handler.attach = function(editor) {
replacement : undefined);
}
return lastMark;
}
};
editor.on("click", $resetMarkMode);
editor.on("changeSession", $kbSessionChange);
@ -808,7 +809,7 @@ exports.handler.getStatusText = function(editor, data) {
if (data.count)
str += data.count;
if (data.keyChain)
str += " " + data.keyChain
str += " " + data.keyChain;
return str;
};
@ -870,7 +871,7 @@ exports.handler.handleKeyboard = function(data, hashId, key, keyCode) {
data.lastCommand = null;
if (!command.readOnly && editor.emacsMark())
editor.setEmacsMark(null)
editor.setEmacsMark(null);
if (data.count) {
var count = data.count;
@ -1063,17 +1064,27 @@ exports.handler.addCommands({
},
killLine: function(editor) {
editor.pushEmacsMark(null);
var pos = editor.getCursorPosition();
if (pos.column === 0 &&
editor.session.doc.getLine(pos.row).length === 0) {
editor.selection.selectLine();
} else {
editor.clearSelection();
editor.selection.selectLineEnd();
}
editor.clearSelection();
var range = editor.getSelectionRange();
var line = editor.session.getLine(range.start.row);
range.end.column = line.length;
line = line.substr(range.start.column);
var foldLine = editor.session.getFoldLine(range.start.row);
if (foldLine && range.end.row != foldLine.end.row) {
range.end.row = foldLine.end.row;
line = "x";
}
if (/^\s*$/.test(line)) {
range.end.row++;
line = editor.session.getLine(range.end.row);
range.end.column = /^\s*$/.test(line) ? line.length : 0;
}
var text = editor.session.getTextRange(range);
exports.killRing.add(text);
if (editor.prevOp.command == this)
exports.killRing.append(text);
else
exports.killRing.add(text);
editor.session.remove(range);
editor.clearSelection();
@ -1094,6 +1105,7 @@ exports.handler.addCommands({
exec: function(editor) {
exports.killRing.add(editor.getCopyText());
editor.commands.byName.cut.exec(editor);
editor.setEmacsMark(null);
},
readOnly: true,
multiSelectAction: "forEach"
@ -1145,6 +1157,12 @@ exports.killRing = {
if (this.$data.length > 30)
this.$data.shift();
},
append: function(str) {
var idx = this.$data.length - 1;
var text = this.$data[idx] || "";
if (str) text += str;
if (text) this.$data[idx] = text;
},
get: function(n) {
n = n || 1;
return this.$data.slice(this.$data.length-n, this.$data.length).reverse().join('\n');