vim-sim 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +30 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3929,24 +3929,38 @@ function pasteCharacterwise(state, content, position) {
|
|
|
3929
3929
|
const lines = state.buffer.content.split("\n");
|
|
3930
3930
|
const currentLineIndex = state.cursor.line;
|
|
3931
3931
|
const currentLine2 = lines[currentLineIndex] ?? "";
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
newLine = beforeCursor + content + afterCursor;
|
|
3938
|
-
newColumn = state.cursor.column + content.length;
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3932
|
+
const contentLines = content.split("\n");
|
|
3933
|
+
const splitPoint = position === "after" ? state.cursor.column + 1 : state.cursor.column;
|
|
3934
|
+
const beforeCursor = currentLine2.substring(0, splitPoint);
|
|
3935
|
+
const afterCursor = currentLine2.substring(splitPoint);
|
|
3936
|
+
if (contentLines.length === 1) {
|
|
3937
|
+
const newLine = beforeCursor + content + afterCursor;
|
|
3938
|
+
const newColumn = position === "after" ? state.cursor.column + content.length : state.cursor.column + content.length - 1;
|
|
3939
|
+
lines[currentLineIndex] = newLine;
|
|
3940
|
+
return {
|
|
3941
|
+
...state,
|
|
3942
|
+
buffer: new Buffer(lines.join("\n")),
|
|
3943
|
+
cursor: new Cursor(currentLineIndex, Math.max(0, newColumn))
|
|
3944
|
+
};
|
|
3945
|
+
}
|
|
3946
|
+
const firstContentLine = contentLines[0];
|
|
3947
|
+
const lastContentLine = contentLines[contentLines.length - 1];
|
|
3948
|
+
const middleContentLines = contentLines.slice(1, -1);
|
|
3949
|
+
const newFirstLine = beforeCursor + firstContentLine;
|
|
3950
|
+
const newLastLine = lastContentLine + afterCursor;
|
|
3951
|
+
const newLines = [
|
|
3952
|
+
...lines.slice(0, currentLineIndex),
|
|
3953
|
+
newFirstLine,
|
|
3954
|
+
...middleContentLines,
|
|
3955
|
+
newLastLine,
|
|
3956
|
+
...lines.slice(currentLineIndex + 1)
|
|
3957
|
+
];
|
|
3958
|
+
const newCursorLine = currentLineIndex + contentLines.length - 1;
|
|
3959
|
+
const newCursorColumn = Math.max(0, lastContentLine.length - 1);
|
|
3946
3960
|
return {
|
|
3947
3961
|
...state,
|
|
3948
|
-
buffer: new Buffer(
|
|
3949
|
-
cursor: new Cursor(
|
|
3962
|
+
buffer: new Buffer(newLines.join("\n")),
|
|
3963
|
+
cursor: new Cursor(newCursorLine, newCursorColumn)
|
|
3950
3964
|
};
|
|
3951
3965
|
}
|
|
3952
3966
|
var p = class extends Command {
|