Skip to content

Commit

Permalink
package 26.09.22
Browse files Browse the repository at this point in the history
  • Loading branch information
anester-aws committed Sep 26, 2022
1 parent a1f6ab9 commit 6526ea4
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 24 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [1.11.2](https://github.com/ajaxorg/ace/compare/v1.11.1...v1.11.2) (2022-09-26)


### Bug Fixes

* Fixed handling surrogare characters in insert, replace, delete mode in Vim ([72fd4b7](https://github.com/ajaxorg/ace/commit/72fd4b7b616f070be198dc8fc437d48a74637a53))
* Fixed handling surrogate characters in insert-after mode in Vim ([38f893a](https://github.com/ajaxorg/ace/commit/38f893a13b1f1dedea4407a8f3ef1d6098873269))

### [1.11.1](https://github.com/ajaxorg/ace/compare/v1.11.0...v1.11.1) (2022-09-23)


Expand Down
2 changes: 1 addition & 1 deletion kitchen-sink.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta name="author" content="Fabian Jakobs">
<!--
Ace
version 1.11.1
version 1.11.2
commit
-->

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ace-builds",
"main": "./src-noconflict/ace.js",
"typings": "ace.d.ts",
"version": "1.11.1",
"version": "1.11.2",
"description": "Ace (Ajax.org Cloud9 Editor)",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
2 changes: 1 addition & 1 deletion src-min-noconflict/ace.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src-min-noconflict/keybinding-vim.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src-min/ace.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src-min/keybinding-vim.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src-noconflict/ace.js
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ var reportErrorIfPathIsNotConfigured = function () {
reportErrorIfPathIsNotConfigured = function () { };
}
};
exports.version = "1.11.1";
exports.version = "1.11.2";

});

Expand Down
36 changes: 28 additions & 8 deletions src-noconflict/keybinding-vim.js
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,16 @@ function transformCursor(cm, range) {
}
return range.head;
}
function updateSelectionForSurrogateCharacters(cm, curStart, curEnd) {
if (curStart.line === curEnd.line && curStart.ch >= curEnd.ch - 1) {
var text = cm.getLine(curStart.line);
var charCode = text.charCodeAt(curStart.ch);
if (0xD800 <= charCode && charCode <= 0xD8FF) {
curEnd.ch += 1;
}
}
return { start: curStart, end: curEnd };
}
var defaultKeymap = [
{ keys: '<Left>', type: 'keyToKey', toKeys: 'h' },
{ keys: '<Right>', type: 'keyToKey', toKeys: 'l' },
Expand Down Expand Up @@ -2458,9 +2468,10 @@ var commandDispatcher = {
mode = vim.visualBlock ? 'block' :
linewise ? 'line' :
'char';
var newPositions = updateSelectionForSurrogateCharacters(cm, curStart, curEnd);
cmSel = makeCmSelection(cm, {
anchor: curStart,
head: curEnd
anchor: newPositions.start,
head: newPositions.end
}, mode);
if (linewise) {
var ranges = cmSel.ranges;
Expand Down Expand Up @@ -2491,9 +2502,10 @@ var commandDispatcher = {
}
mode = 'char';
var exclusive = !motionArgs.inclusive || linewise;
var newPositions = updateSelectionForSurrogateCharacters(cm, curStart, curEnd);
cmSel = makeCmSelection(cm, {
anchor: curStart,
head: curEnd
anchor: newPositions.start,
head: newPositions.end
}, mode, exclusive);
}
cm.setSelections(cmSel.ranges, cmSel.primary);
Expand Down Expand Up @@ -3213,10 +3225,12 @@ var actions = {
head = new Pos(head.line, 0);
}
else if (insertAt == 'charAfter') {
head = offsetCursor(head, 0, 1);
var newPosition = updateSelectionForSurrogateCharacters(cm, head, offsetCursor(head, 0, 1));
head = newPosition.end;
}
else if (insertAt == 'firstNonBlank') {
head = motions.moveToFirstNonWhiteSpaceCharacter(cm, head);
var newPosition = updateSelectionForSurrogateCharacters(cm, head, motions.moveToFirstNonWhiteSpaceCharacter(cm, head));
head = newPosition.end;
}
else if (insertAt == 'startOfSelectedArea') {
if (!vim.visualMode)
Expand Down Expand Up @@ -3287,9 +3301,10 @@ var actions = {
vim.visualLine = !!actionArgs.linewise;
vim.visualBlock = !!actionArgs.blockwise;
head = clipCursorToContent(cm, new Pos(anchor.line, anchor.ch + repeat - 1));
var newPosition = updateSelectionForSurrogateCharacters(cm, anchor, head);
vim.sel = {
anchor: anchor,
head: head
anchor: newPosition.start,
head: newPosition.end
};
CodeMirror.signal(cm, "vim-mode-change", { mode: "visual", subMode: vim.visualLine ? "linewise" : vim.visualBlock ? "blockwise" : "" });
updateCmSelection(cm);
Expand Down Expand Up @@ -3584,17 +3599,22 @@ var actions = {
}
curEnd = new Pos(curStart.line, replaceTo);
}
var newPositions = updateSelectionForSurrogateCharacters(cm, curStart, curEnd);
curStart = newPositions.start;
curEnd = newPositions.end;
if (replaceWith == '\n') {
if (!vim.visualMode)
cm.replaceRange('', curStart, curEnd);
(CodeMirror.commands.newlineAndIndentContinueComment || CodeMirror.commands.newlineAndIndent)(cm);
}
else {
var replaceWithStr = cm.getRange(curStart, curEnd);
replaceWithStr = replaceWithStr.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, replaceWith);
replaceWithStr = replaceWithStr.replace(/[^\n]/g, replaceWith);
if (vim.visualBlock) {
var spaces = new Array(cm.getOption("tabSize") + 1).join(' ');
replaceWithStr = cm.getSelection();
replaceWithStr = replaceWithStr.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, replaceWith);
replaceWithStr = replaceWithStr.replace(/\t/g, spaces).replace(/[^\n]/g, replaceWith).split('\n');
cm.replaceSelections(replaceWithStr);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ace.js
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ var reportErrorIfPathIsNotConfigured = function () {
reportErrorIfPathIsNotConfigured = function () { };
}
};
exports.version = "1.11.1";
exports.version = "1.11.2";

});

Expand Down
36 changes: 28 additions & 8 deletions src/keybinding-vim.js
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,16 @@ function transformCursor(cm, range) {
}
return range.head;
}
function updateSelectionForSurrogateCharacters(cm, curStart, curEnd) {
if (curStart.line === curEnd.line && curStart.ch >= curEnd.ch - 1) {
var text = cm.getLine(curStart.line);
var charCode = text.charCodeAt(curStart.ch);
if (0xD800 <= charCode && charCode <= 0xD8FF) {
curEnd.ch += 1;
}
}
return { start: curStart, end: curEnd };
}
var defaultKeymap = [
{ keys: '<Left>', type: 'keyToKey', toKeys: 'h' },
{ keys: '<Right>', type: 'keyToKey', toKeys: 'l' },
Expand Down Expand Up @@ -2458,9 +2468,10 @@ var commandDispatcher = {
mode = vim.visualBlock ? 'block' :
linewise ? 'line' :
'char';
var newPositions = updateSelectionForSurrogateCharacters(cm, curStart, curEnd);
cmSel = makeCmSelection(cm, {
anchor: curStart,
head: curEnd
anchor: newPositions.start,
head: newPositions.end
}, mode);
if (linewise) {
var ranges = cmSel.ranges;
Expand Down Expand Up @@ -2491,9 +2502,10 @@ var commandDispatcher = {
}
mode = 'char';
var exclusive = !motionArgs.inclusive || linewise;
var newPositions = updateSelectionForSurrogateCharacters(cm, curStart, curEnd);
cmSel = makeCmSelection(cm, {
anchor: curStart,
head: curEnd
anchor: newPositions.start,
head: newPositions.end
}, mode, exclusive);
}
cm.setSelections(cmSel.ranges, cmSel.primary);
Expand Down Expand Up @@ -3213,10 +3225,12 @@ var actions = {
head = new Pos(head.line, 0);
}
else if (insertAt == 'charAfter') {
head = offsetCursor(head, 0, 1);
var newPosition = updateSelectionForSurrogateCharacters(cm, head, offsetCursor(head, 0, 1));
head = newPosition.end;
}
else if (insertAt == 'firstNonBlank') {
head = motions.moveToFirstNonWhiteSpaceCharacter(cm, head);
var newPosition = updateSelectionForSurrogateCharacters(cm, head, motions.moveToFirstNonWhiteSpaceCharacter(cm, head));
head = newPosition.end;
}
else if (insertAt == 'startOfSelectedArea') {
if (!vim.visualMode)
Expand Down Expand Up @@ -3287,9 +3301,10 @@ var actions = {
vim.visualLine = !!actionArgs.linewise;
vim.visualBlock = !!actionArgs.blockwise;
head = clipCursorToContent(cm, new Pos(anchor.line, anchor.ch + repeat - 1));
var newPosition = updateSelectionForSurrogateCharacters(cm, anchor, head);
vim.sel = {
anchor: anchor,
head: head
anchor: newPosition.start,
head: newPosition.end
};
CodeMirror.signal(cm, "vim-mode-change", { mode: "visual", subMode: vim.visualLine ? "linewise" : vim.visualBlock ? "blockwise" : "" });
updateCmSelection(cm);
Expand Down Expand Up @@ -3584,17 +3599,22 @@ var actions = {
}
curEnd = new Pos(curStart.line, replaceTo);
}
var newPositions = updateSelectionForSurrogateCharacters(cm, curStart, curEnd);
curStart = newPositions.start;
curEnd = newPositions.end;
if (replaceWith == '\n') {
if (!vim.visualMode)
cm.replaceRange('', curStart, curEnd);
(CodeMirror.commands.newlineAndIndentContinueComment || CodeMirror.commands.newlineAndIndent)(cm);
}
else {
var replaceWithStr = cm.getRange(curStart, curEnd);
replaceWithStr = replaceWithStr.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, replaceWith);
replaceWithStr = replaceWithStr.replace(/[^\n]/g, replaceWith);
if (vim.visualBlock) {
var spaces = new Array(cm.getOption("tabSize") + 1).join(' ');
replaceWithStr = cm.getSelection();
replaceWithStr = replaceWithStr.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, replaceWith);
replaceWithStr = replaceWithStr.replace(/\t/g, spaces).replace(/[^\n]/g, replaceWith).split('\n');
cm.replaceSelections(replaceWithStr);
}
Expand Down

0 comments on commit 6526ea4

Please sign in to comment.