mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-21 04:20:11 -04:00
Initial VS Code 1.19 source merge (#571)
* Initial 1.19 xcopy * Fix yarn build * Fix numerous build breaks * Next batch of build break fixes * More build break fixes * Runtime breaks * Additional post merge fixes * Fix windows setup file * Fix test failures. * Update license header blocks to refer to source eula
This commit is contained in:
@@ -0,0 +1,201 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { DeleteLinesCommand } from 'vs/editor/contrib/linesOperations/deleteLinesCommand';
|
||||
import { testCommand } from 'vs/editor/test/browser/testCommand';
|
||||
|
||||
function createFromSelection(selection: Selection): DeleteLinesCommand {
|
||||
var endLineNumber = selection.endLineNumber;
|
||||
if (selection.startLineNumber < selection.endLineNumber && selection.endColumn === 1) {
|
||||
endLineNumber -= 1;
|
||||
}
|
||||
return new DeleteLinesCommand(selection.startLineNumber, endLineNumber, selection.positionColumn);
|
||||
}
|
||||
|
||||
function testDeleteLinesCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {
|
||||
testCommand(lines, null, selection, (sel) => createFromSelection(sel), expectedLines, expectedSelection);
|
||||
}
|
||||
|
||||
suite('Editor Contrib - Delete Lines Command', () => {
|
||||
|
||||
test('empty selection in middle of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 3, 2, 3),
|
||||
[
|
||||
'first',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 3, 2, 3)
|
||||
);
|
||||
});
|
||||
|
||||
test('empty selection at top of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 1, 5),
|
||||
[
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
test('empty selection at end of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(5, 2, 5, 2),
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line'
|
||||
],
|
||||
new Selection(4, 2, 4, 2)
|
||||
);
|
||||
});
|
||||
|
||||
test('with selection in middle of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(3, 3, 2, 2),
|
||||
[
|
||||
'first',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 2, 2, 2)
|
||||
);
|
||||
});
|
||||
|
||||
test('with selection at top of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 4, 1, 5),
|
||||
[
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
test('with selection at end of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(5, 1, 5, 2),
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line'
|
||||
],
|
||||
new Selection(4, 2, 4, 2)
|
||||
);
|
||||
});
|
||||
|
||||
test('with full line selection in middle of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(4, 1, 2, 1),
|
||||
[
|
||||
'first',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 1, 2, 1)
|
||||
);
|
||||
});
|
||||
|
||||
test('with full line selection at top of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(2, 1, 1, 5),
|
||||
[
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(1, 5, 1, 5)
|
||||
);
|
||||
});
|
||||
|
||||
test('with full line selection at end of lines', function () {
|
||||
testDeleteLinesCommand(
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line',
|
||||
'fourth line',
|
||||
'fifth'
|
||||
],
|
||||
new Selection(4, 1, 5, 2),
|
||||
[
|
||||
'first',
|
||||
'second line',
|
||||
'third line'
|
||||
],
|
||||
new Selection(3, 2, 3, 2)
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user