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

@ -58,7 +58,7 @@ define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/eve
CodeMirror.commands = {
redo: function(cm) { cm.ace.redo(); },
undo: function(cm) { cm.ace.undo(); },
newlineAndIndent: function(cm) { cm.ace.insert("\n"); },
newlineAndIndent: function(cm) { cm.ace.insert("\n"); }
};
CodeMirror.keyMap = {};
CodeMirror.addClass = CodeMirror.rmClass =
@ -118,17 +118,15 @@ define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/eve
return this.ace.inVirtualSelectionMode && this.ace.selection.index;
};
this.onChange = function(delta) {
if (delta.action[0] == 'i') {
var change = { text: delta.lines };
var curOp = this.curOp = this.curOp || {};
if (!curOp.changeHandlers)
curOp.changeHandlers = this._eventRegistry["change"] && this._eventRegistry["change"].slice();
if (this.virtualSelectionMode()) return;
if (!curOp.lastChange) {
curOp.lastChange = curOp.change = change;
} else {
curOp.lastChange.next = curOp.lastChange = change;
}
var change = { text: delta.action[0] == 'i' ? delta.lines : [] };
var curOp = this.curOp = this.curOp || {};
if (!curOp.changeHandlers)
curOp.changeHandlers = this._eventRegistry["change"] && this._eventRegistry["change"].slice();
if (this.virtualSelectionMode()) return;
if (!curOp.lastChange) {
curOp.lastChange = curOp.change = change;
} else {
curOp.lastChange.next = curOp.lastChange = change;
}
this.$updateMarkers(delta);
};
@ -828,9 +826,9 @@ dom.importCssString(".normal-mode .ace_cursor{\
{ keys: '<C-[>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' },
{ keys: '<C-c>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' },
{ keys: 's', type: 'keyToKey', toKeys: 'cl', context: 'normal' },
{ keys: 's', type: 'keyToKey', toKeys: 'xi', context: 'visual'},
{ keys: 's', type: 'keyToKey', toKeys: 'c', context: 'visual'},
{ keys: 'S', type: 'keyToKey', toKeys: 'cc', context: 'normal' },
{ keys: 'S', type: 'keyToKey', toKeys: 'dcc', context: 'visual' },
{ keys: 'S', type: 'keyToKey', toKeys: 'VdO', context: 'visual' },
{ keys: '<Home>', type: 'keyToKey', toKeys: '0' },
{ keys: '<End>', type: 'keyToKey', toKeys: '$' },
{ keys: '<PageUp>', type: 'keyToKey', toKeys: '<C-b>' },
@ -923,6 +921,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
{ keys: 'v', type: 'action', action: 'toggleVisualMode' },
{ keys: 'V', type: 'action', action: 'toggleVisualMode', actionArgs: { linewise: true }},
{ keys: '<C-v>', type: 'action', action: 'toggleVisualMode', actionArgs: { blockwise: true }},
{ keys: '<C-q>', type: 'action', action: 'toggleVisualMode', actionArgs: { blockwise: true }},
{ keys: 'gv', type: 'action', action: 'reselectLastSelection' },
{ keys: 'J', type: 'action', action: 'joinLines', isEdit: true },
{ keys: 'p', type: 'action', action: 'paste', isEdit: true, actionArgs: { after: true, isEdit: true }},
@ -1037,10 +1036,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
if (key.charAt(0) == '\'') {
return key.charAt(1);
}
var pieces = key.split('-');
if (/-$/.test(key)) {
pieces.splice(-2, 2, '-');
}
var pieces = key.split(/-(?!$)/);
var lastPiece = pieces[pieces.length - 1];
if (pieces.length == 1 && pieces[0].length == 1) {
return false;
@ -1379,7 +1375,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
exCommandDispatcher.map(lhs, rhs, ctx);
},
unmap: function(lhs, ctx) {
exCommandDispatcher.unmap(lhs, ctx || "normal");
exCommandDispatcher.unmap(lhs, ctx);
},
setOption: setOption,
getOption: getOption,
@ -1456,15 +1452,19 @@ dom.importCssString(".normal-mode .ace_cursor{\
if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); }
if (keysAreChars) {
var here = cm.getCursor();
cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
var selections = cm.listSelections();
for (var i = 0; i < selections.length; i++) {
var here = selections[i].head;
cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
}
vimGlobalState.macroModeState.lastInsertModeChanges.changes.pop();
}
clearInputState(cm);
return match.command;
}
function handleKeyNonInsertMode() {
if (handleMacroRecording() || handleEsc()) { return true; };
if (handleMacroRecording() || handleEsc()) { return true; }
var keys = vim.inputState.keyBuffer = vim.inputState.keyBuffer + key;
if (/^[1-9]\d*$/.test(keys)) { return true; }
@ -1491,7 +1491,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
if (command === false) {
return undefined;
} else if (command === true) {
return function() {};
return function() { return true; };
} else {
return function() {
if ((command.operator || command.isEdit) && cm.getOption('readOnly'))
@ -1729,7 +1729,9 @@ dom.importCssString(".normal-mode .ace_cursor{\
}
}
if (bestMatch.keys.slice(-11) == '<character>') {
inputState.selectedCharacter = lastChar(keys);
var character = lastChar(keys);
if (/<C-.>/.test(character)) return {type: 'none'};
inputState.selectedCharacter = character;
}
return {type: 'full', command: bestMatch};
},
@ -2024,7 +2026,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
return;
}
if (motionArgs.toJumplist) {
if (!operator)
if (!operator && cm.ace.curOp != null)
cm.ace.curOp.command.scrollIntoView = "center-animate"; // ace_patch
var jumpList = vimGlobalState.jumpList;
var cachedCursor = jumpList.cachedCursor;
@ -2276,12 +2278,14 @@ dom.importCssString(".normal-mode .ace_cursor{\
(line > last && cur.line == last)) {
return;
}
var fold = cm.ace.session.getFoldAt(line, endCh);
var fold = cm.ace.session.getFoldLine(line);
if (fold) {
if (motionArgs.forward)
line = fold.end.row + 1;
else
line = fold.start.row - 1;
if (motionArgs.forward) {
if (line > fold.start.row)
line = fold.end.row + 1;
} else {
line = fold.start.row;
}
}
if (motionArgs.toFirstChar){
endCh=findFirstNonWhiteSpaceCharacter(cm.getLine(line));
@ -2513,11 +2517,19 @@ dom.importCssString(".normal-mode .ace_cursor{\
text = text.slice(0, - match[0].length);
}
}
var wasLastLine = head.line - 1 == cm.lastLine();
cm.replaceRange('', anchor, head);
if (args.linewise && !wasLastLine) {
CodeMirror.commands.newlineAndIndent(cm);
anchor.ch = null;
var prevLineEnd = new Pos(anchor.line - 1, Number.MAX_VALUE);
var wasLastLine = cm.firstLine() == cm.lastLine();
if (head.line > cm.lastLine() && args.linewise && !wasLastLine) {
cm.replaceRange('', prevLineEnd, head);
} else {
cm.replaceRange('', anchor, head);
}
if (args.linewise) {
if (!wasLastLine) {
cm.setCursor(prevLineEnd);
CodeMirror.commands.newlineAndIndent(cm);
}
anchor.ch = Number.MAX_VALUE;
}
finalHead = anchor;
} else {
@ -3815,8 +3827,17 @@ dom.importCssString(".normal-mode .ace_cursor{\
if (any) { return isEmpty(i) != isEmpty(i + dir); }
return !isEmpty(i) && isEmpty(i + dir);
}
function skipFold(i) {
dir = dir > 0 ? 1 : -1;
var foldLine = cm.ace.session.getFoldLine(i);
if (foldLine) {
if (i + dir > foldLine.start.row && i + dir < foldLine.end.row)
dir = (dir > 0 ? foldLine.end.row : foldLine.start.row) - i;
}
}
if (dir) {
while (min <= i && i <= max && repeat > 0) {
skipFold(i);
if (isBoundary(i, dir)) { repeat--; }
i += dir;
}
@ -4470,7 +4491,6 @@ dom.importCssString(".normal-mode .ace_cursor{\
}
}
}
throw Error('No such mapping.');
}
};
@ -4604,7 +4624,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
if (decimal + hex + octal > 1) { return 'Invalid arguments'; }
number = decimal && 'decimal' || hex && 'hex' || octal && 'octal';
}
if (args.eatSpace() && args.match(/\/.*\//)) { 'patterns not supported'; }
if (args.match(/\/.*\//)) { return 'patterns not supported'; }
}
}
var err = parseArgs();
@ -4920,7 +4940,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
}
if (!confirm) {
replaceAll();
if (callback) { callback(); };
if (callback) { callback(); }
return;
}
showPrompt(cm, {
@ -4969,6 +4989,8 @@ dom.importCssString(".normal-mode .ace_cursor{\
cm.setCursor(cm.getCursor().line, cm.getCursor().ch-1);
cm.setOption('keyMap', 'vim');
cm.setOption('disableInput', true);
lastChange.overwrite = cm.state.overwrite;
cm.toggleOverwrite(false); // exit replace mode if we were in it.
insertModeChangeRegister.setText(lastChange.changes.join(''));
CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"});
@ -5042,7 +5064,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
exitInsertMode(cm);
}
}
};
}
macroModeState.isPlaying = false;
}
@ -5081,6 +5103,10 @@ dom.importCssString(".normal-mode .ace_cursor{\
if (changeObj.origin == '+input' || changeObj.origin == 'paste'
|| changeObj.origin === undefined /* only in testing */) {
var text = changeObj.text.join('\n');
if (lastChange.maybeReset) {
lastChange.changes = [];
lastChange.maybeReset = false;
}
lastChange.changes.push(text);
}
changeObj = changeObj.next;
@ -5096,7 +5122,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
if (lastChange.expectCursorActivityForChange) {
lastChange.expectCursorActivityForChange = false;
} else {
lastChange.changes = [];
lastChange.maybeReset = true;
}
} else if (!cm.curOp.isVimOp) {
handleExternalSelection(cm, vim);
@ -5148,6 +5174,10 @@ dom.importCssString(".normal-mode .ace_cursor{\
var keyName = CodeMirror.keyName(e);
if (!keyName) { return; }
function onKeyFound() {
if (lastChange.maybeReset) {
lastChange.changes = [];
lastChange.maybeReset = false;
}
lastChange.changes.push(new InsertModeKey(keyName));
return true;
}
@ -5171,7 +5201,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
if (macroModeState.lastInsertModeChanges.changes.length > 0) {
repeat = !vim.lastEditActionCommand ? 1 : repeat;
var changeObject = macroModeState.lastInsertModeChanges;
repeatInsertModeChanges(cm, changeObject.changes, repeat);
repeatInsertModeChanges(cm, changeObject.changes, repeat, changeObject.overwrite);
}
}
vim.inputState = vim.lastEditInputState;
@ -5191,9 +5221,9 @@ dom.importCssString(".normal-mode .ace_cursor{\
exitInsertMode(cm);
}
macroModeState.isPlaying = false;
};
}
function repeatInsertModeChanges(cm, changes, repeat) {
function repeatInsertModeChanges(cm, changes, repeat, overwrite) {
function keyHandler(binding) {
if (typeof binding == 'string') {
CodeMirror.commands[binding](cm);
@ -5222,7 +5252,11 @@ dom.importCssString(".normal-mode .ace_cursor{\
CodeMirror.lookupKey(change.keyName, 'vim-insert', keyHandler);
} else {
var cur = cm.getCursor();
cm.replaceRange(change, cur, cur);
var end = cur;
if (overwrite && !/\n/.test(change)) {
end = offsetCursor(cur, 0, change.length);
}
cm.replaceRange(change, cur, end);
}
}
}
@ -5520,7 +5554,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
defaultKeymap.push(
{ keys: 'zc', type: 'action', action: 'fold', actionArgs: { open: false } },
{ keys: 'zC', type: 'action', action: 'fold', actionArgs: { open: false, all: true } },
{ keys: 'zo', type: 'action', action: 'fold', actionArgs: { open: true, } },
{ keys: 'zo', type: 'action', action: 'fold', actionArgs: { open: true } },
{ keys: 'zO', type: 'action', action: 'fold', actionArgs: { open: true, all: true } },
{ keys: 'za', type: 'action', action: 'fold', actionArgs: { toggle: true } },
{ keys: 'zA', type: 'action', action: 'fold', actionArgs: { toggle: true, all: true } },
@ -5554,7 +5588,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
actions.fold = function(cm, actionArgs, vim) {
cm.ace.execCommand(['toggleFoldWidget', 'toggleFoldWidget', 'foldOther', 'unfoldall'
][(actionArgs.all ? 2 : 0) + (actionArgs.open ? 1 : 0)]);
},
};
exports.handler.defaultKeymap = defaultKeymap;
exports.handler.actions = actions;