Skip to content

Commit 885eb8d

Browse files
Fixes microsoft#26393 by changing the default behavior of InsertCursorAbove/Below
1 parent fae8d1f commit 885eb8d

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

src/vs/editor/contrib/multicursor/multicursor.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ export class InsertCursorAbove extends EditorAction {
7070
return;
7171
}
7272

73-
const useLogicalLine = (args && args.logicalLine === true);
73+
let useLogicalLine = true;
74+
if (args && args.logicalLine === false) {
75+
useLogicalLine = false;
76+
}
7477
const viewModel = editor._getViewModel();
7578

7679
if (viewModel.cursorConfig.readOnly) {
@@ -120,7 +123,10 @@ export class InsertCursorBelow extends EditorAction {
120123
return;
121124
}
122125

123-
const useLogicalLine = (args && args.logicalLine === true);
126+
let useLogicalLine = true;
127+
if (args && args.logicalLine === false) {
128+
useLogicalLine = false;
129+
}
124130
const viewModel = editor._getViewModel();
125131

126132
if (viewModel.cursorConfig.readOnly) {

src/vs/editor/contrib/multicursor/test/multicursor.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,31 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
1616

1717
suite('Multicursor', () => {
1818

19+
20+
test('issue #26393: Multiple cursors + Word wrap', () => {
21+
withTestCodeEditor([
22+
'a'.repeat(20),
23+
'a'.repeat(20),
24+
], { wordWrap: 'wordWrapColumn', wordWrapColumn: 10 }, (editor, viewModel) => {
25+
let addCursorDownAction = new InsertCursorBelow();
26+
addCursorDownAction.run(null!, editor, {});
27+
28+
assert.strictEqual(viewModel.getCursorStates().length, 2);
29+
30+
assert.strictEqual(viewModel.getCursorStates()[0].viewState.position.lineNumber, 1);
31+
assert.strictEqual(viewModel.getCursorStates()[1].viewState.position.lineNumber, 3);
32+
33+
editor.setPosition({ lineNumber: 4, column: 1 });
34+
let addCursorUpAction = new InsertCursorAbove();
35+
addCursorUpAction.run(null!, editor, {});
36+
37+
assert.strictEqual(viewModel.getCursorStates().length, 2);
38+
39+
assert.strictEqual(viewModel.getCursorStates()[0].viewState.position.lineNumber, 4);
40+
assert.strictEqual(viewModel.getCursorStates()[1].viewState.position.lineNumber, 2);
41+
});
42+
});
43+
1944
test('issue #2205: Multi-cursor pastes in reverse order', () => {
2045
withTestCodeEditor([
2146
'abc',

0 commit comments

Comments
 (0)