Update ACE Editor to version 1.2.0
Previously, we were at an ACE editor published between 1.1.8 and 1.1.9. This caused multiple issues and was especially a problem for the upcoming pair programming feature. Further, updating ace is a long-time priority, see https://github.com/openHPI/codeocean/issues/250. Now, we are not yet updating to the latest version, but rather to the next minor version. This already contains breaking changes, and we are currently interested to keep the number of changes as low as possible. Further updating ACE might be still a future task. The new ACE version 1.2.0 is taken from this tag: https://github.com/ajaxorg/ace-builds/releases/tag/v1.2.0. We are using the src build (not minified, not in the noconflict version), since the same was used before as well. Further, we need to change our migration for storing editor events. Since the table is not yet used (in production), we also update the enum.
This commit is contained in:
@ -356,26 +356,49 @@ var CodeOceanEditor = {
|
||||
},
|
||||
|
||||
handleUTF16Surrogates: function (AceDeltaObject, AceSession) {
|
||||
if (AceDeltaObject.data === undefined || AceDeltaObject.data.action !== "removeText") {
|
||||
if (_.isEmpty(AceDeltaObject.lines) || AceDeltaObject.action !== "remove") {
|
||||
return;
|
||||
}
|
||||
|
||||
const codePoint = AceDeltaObject.data.text.codePointAt(0);
|
||||
if (0xDC00 <= codePoint && codePoint <= 0xDFFF) {
|
||||
const firstCodePoint = AceDeltaObject.lines[0].codePointAt(0);
|
||||
if (0xDC00 <= firstCodePoint && firstCodePoint <= 0xDFFF) {
|
||||
// The text contains a UTF-16 surrogate pair, and the only the lower part is removed.
|
||||
// We need to remove the high surrogate pair as well.
|
||||
const currentCharacter = AceDeltaObject.data.range
|
||||
const previousCharacter = {
|
||||
start: {
|
||||
row: currentCharacter.start.row,
|
||||
column: currentCharacter.start.column - 1
|
||||
row: AceDeltaObject.start.row,
|
||||
column: AceDeltaObject.start.column - 1
|
||||
},
|
||||
end: {
|
||||
row: currentCharacter.start.row,
|
||||
column: currentCharacter.start.column
|
||||
row: AceDeltaObject.start.row,
|
||||
column: AceDeltaObject.start.column
|
||||
}
|
||||
}
|
||||
AceSession.remove(previousCharacter);
|
||||
const previousCharacterCodePoint = AceSession.getTextRange(previousCharacter).codePointAt(0);
|
||||
if (0xD800 <= previousCharacterCodePoint && previousCharacterCodePoint <= 0xDBFF) {
|
||||
AceSession.remove(previousCharacter);
|
||||
}
|
||||
}
|
||||
|
||||
const lastLine = AceDeltaObject.lines.slice(-1)[0];
|
||||
const lastCodePoint = lastLine.codePointAt(lastLine.length - 1);
|
||||
if (0xD800 <= lastCodePoint && lastCodePoint <= 0xDBFF) {
|
||||
// The text contains a UTF-16 surrogate pair, and the only the higher part is removed.
|
||||
// We need to remove the high surrogate pair as well.
|
||||
const nextCharacter = {
|
||||
start: {
|
||||
row: AceDeltaObject.end.row,
|
||||
column: AceDeltaObject.end.column - 1
|
||||
},
|
||||
end: {
|
||||
row: AceDeltaObject.end.row,
|
||||
column: AceDeltaObject.end.column
|
||||
}
|
||||
}
|
||||
const nextCharacterCodePoint = AceSession.getTextRange(nextCharacter).codePointAt(0);
|
||||
if (0xDC00 <= nextCharacterCodePoint && nextCharacterCodePoint <= 0xDFFF) {
|
||||
AceSession.remove(nextCharacter);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user