提交 f6aef925 编写于 作者: A Alex Dima

Test & tweaks

上级 e4040bef
......@@ -265,7 +265,7 @@ interface IDeleteLinesOperation {
positionColumn: number;
}
class DeleteLinesAction extends EditorAction {
export class DeleteLinesAction extends EditorAction {
constructor() {
super({
......@@ -313,6 +313,9 @@ class DeleteLinesAction extends EditorAction {
// Sort delete operations
operations.sort((a, b) => {
if (a.startLineNumber === b.startLineNumber) {
return a.endLineNumber - b.endLineNumber;
}
return a.startLineNumber - b.startLineNumber;
});
......@@ -322,7 +325,7 @@ class DeleteLinesAction extends EditorAction {
for (let i = 1; i < operations.length; i++) {
if (previousOperation.endLineNumber + 1 >= operations[i].startLineNumber) {
// Merge current operations into the previous one
previousOperation.endLineNumber = Math.max(previousOperation.endLineNumber, operations[i].endLineNumber);
previousOperation.endLineNumber = operations[i].endLineNumber;
} else {
// Push previous operation
mergedOperations.push(previousOperation);
......
......@@ -9,7 +9,7 @@ import { Position } from 'vs/editor/common/core/position';
import { Selection } from 'vs/editor/common/core/selection';
import { Handler } from 'vs/editor/common/editorCommon';
import { ITextModel } from 'vs/editor/common/model';
import { DeleteAllLeftAction, DeleteAllRightAction, IndentLinesAction, InsertLineAfterAction, InsertLineBeforeAction, JoinLinesAction, LowerCaseAction, SortLinesAscendingAction, SortLinesDescendingAction, TransposeAction, UpperCaseAction } from 'vs/editor/contrib/linesOperations/linesOperations';
import { DeleteAllLeftAction, DeleteAllRightAction, IndentLinesAction, InsertLineAfterAction, InsertLineBeforeAction, JoinLinesAction, LowerCaseAction, SortLinesAscendingAction, SortLinesDescendingAction, TransposeAction, UpperCaseAction, DeleteLinesAction } from 'vs/editor/contrib/linesOperations/linesOperations';
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
import { createTextModel } from 'vs/editor/test/common/editorTestUtils';
......@@ -879,4 +879,24 @@ suite('Editor Contrib - Line Operations', () => {
model.dispose();
});
test('issue #62112: Delete line does not work properly when multiple cursors are on line', () => {
const TEXT = [
'a',
'foo boo',
'too',
'c',
];
withTestCodeEditor(TEXT, {}, (editor, cursor) => {
editor.setSelections([
new Selection(2, 4, 2, 4),
new Selection(2, 8, 2, 8),
new Selection(3, 4, 3, 4),
]);
const deleteLinesAction = new DeleteLinesAction();
deleteLinesAction.run(null, editor);
assert.equal(editor.getValue(), 'a\nc');
});
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册