Skip to content

Commit

Permalink
Merge pull request #135805 from martinzimmermann/fix-26393
Browse files Browse the repository at this point in the history
Fixes #26393 by changing the default behavior of InsertCursorAbove/Below
  • Loading branch information
alexdima committed Oct 27, 2021
2 parents 7d8f55e + a696fa1 commit c0d3263
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/vs/editor/contrib/multicursor/multicursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ export class InsertCursorAbove extends EditorAction {
return;
}

const useLogicalLine = (args && args.logicalLine === true);
let useLogicalLine = true;
if (args && args.logicalLine === false) {
useLogicalLine = false;
}
const viewModel = editor._getViewModel();

if (viewModel.cursorConfig.readOnly) {
Expand Down Expand Up @@ -120,7 +123,10 @@ export class InsertCursorBelow extends EditorAction {
return;
}

const useLogicalLine = (args && args.logicalLine === true);
let useLogicalLine = true;
if (args && args.logicalLine === false) {
useLogicalLine = false;
}
const viewModel = editor._getViewModel();

if (viewModel.cursorConfig.readOnly) {
Expand Down
25 changes: 25 additions & 0 deletions src/vs/editor/contrib/multicursor/test/multicursor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@ import { IStorageService } from 'vs/platform/storage/common/storage';

suite('Multicursor', () => {


test('issue #26393: Multiple cursors + Word wrap', () => {
withTestCodeEditor([
'a'.repeat(20),
'a'.repeat(20),
], { wordWrap: 'wordWrapColumn', wordWrapColumn: 10 }, (editor, viewModel) => {
let addCursorDownAction = new InsertCursorBelow();
addCursorDownAction.run(null!, editor, {});

assert.strictEqual(viewModel.getCursorStates().length, 2);

assert.strictEqual(viewModel.getCursorStates()[0].viewState.position.lineNumber, 1);
assert.strictEqual(viewModel.getCursorStates()[1].viewState.position.lineNumber, 3);

editor.setPosition({ lineNumber: 4, column: 1 });
let addCursorUpAction = new InsertCursorAbove();
addCursorUpAction.run(null!, editor, {});

assert.strictEqual(viewModel.getCursorStates().length, 2);

assert.strictEqual(viewModel.getCursorStates()[0].viewState.position.lineNumber, 4);
assert.strictEqual(viewModel.getCursorStates()[1].viewState.position.lineNumber, 2);
});
});

test('issue #2205: Multi-cursor pastes in reverse order', () => {
withTestCodeEditor([
'abc',
Expand Down

0 comments on commit c0d3263

Please sign in to comment.