mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-18 19:11:36 -04:00
Merge from master
This commit is contained in:
@@ -2,32 +2,30 @@
|
||||
* 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 * as assert from 'assert';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
|
||||
import {
|
||||
DeleteWordPartLeft, DeleteWordPartRight,
|
||||
CursorWordPartLeft, CursorWordPartRight
|
||||
} from 'vs/editor/contrib/wordPartOperations/wordPartOperations';
|
||||
import { EditorCommand } from 'vs/editor/browser/editorExtensions';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorCommand } from 'vs/editor/browser/editorExtensions';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { deserializePipePositions, serializePipePositions, testRepeatedActionAndExtractPositions } from 'vs/editor/contrib/wordOperations/test/wordTestUtils';
|
||||
import { CursorWordPartLeft, CursorWordPartLeftSelect, CursorWordPartRight, CursorWordPartRightSelect, DeleteWordPartLeft, DeleteWordPartRight } from 'vs/editor/contrib/wordPartOperations/wordPartOperations';
|
||||
|
||||
suite('WordPartOperations', () => {
|
||||
const _deleteWordPartLeft = new DeleteWordPartLeft();
|
||||
const _deleteWordPartRight = new DeleteWordPartRight();
|
||||
const _cursorWordPartLeft = new CursorWordPartLeft();
|
||||
const _cursorWordPartLeftSelect = new CursorWordPartLeftSelect();
|
||||
const _cursorWordPartRight = new CursorWordPartRight();
|
||||
const _cursorWordPartRightSelect = new CursorWordPartRightSelect();
|
||||
|
||||
function runEditorCommand(editor: ICodeEditor, command: EditorCommand): void {
|
||||
command.runEditorCommand(null, editor, null);
|
||||
}
|
||||
function moveWordPartLeft(editor: ICodeEditor, inSelectionmode: boolean = false): void {
|
||||
runEditorCommand(editor, inSelectionmode ? _cursorWordPartLeft : _cursorWordPartLeft);
|
||||
function cursorWordPartLeft(editor: ICodeEditor, inSelectionmode: boolean = false): void {
|
||||
runEditorCommand(editor, inSelectionmode ? _cursorWordPartLeftSelect : _cursorWordPartLeft);
|
||||
}
|
||||
function moveWordPartRight(editor: ICodeEditor, inSelectionmode: boolean = false): void {
|
||||
runEditorCommand(editor, inSelectionmode ? _cursorWordPartLeft : _cursorWordPartRight);
|
||||
function cursorWordPartRight(editor: ICodeEditor, inSelectionmode: boolean = false): void {
|
||||
runEditorCommand(editor, inSelectionmode ? _cursorWordPartRightSelect : _cursorWordPartRight);
|
||||
}
|
||||
function deleteWordPartLeft(editor: ICodeEditor): void {
|
||||
runEditorCommand(editor, _deleteWordPartLeft);
|
||||
@@ -36,213 +34,142 @@ suite('WordPartOperations', () => {
|
||||
runEditorCommand(editor, _deleteWordPartRight);
|
||||
}
|
||||
|
||||
test('move word part left basic', () => {
|
||||
withTestCodeEditor([
|
||||
'start line',
|
||||
'thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse',
|
||||
'end line'
|
||||
], {}, (editor, _) => {
|
||||
editor.setPosition(new Position(3, 8));
|
||||
const expectedStops = [
|
||||
[3, 5],
|
||||
[3, 4],
|
||||
[3, 1],
|
||||
[2, 81],
|
||||
[2, 78],
|
||||
[2, 73],
|
||||
[2, 70],
|
||||
[2, 66],
|
||||
[2, 65],
|
||||
[2, 59],
|
||||
[2, 54],
|
||||
[2, 51],
|
||||
[2, 47],
|
||||
[2, 46],
|
||||
[2, 42],
|
||||
[2, 37],
|
||||
[2, 31],
|
||||
[2, 29],
|
||||
[2, 26],
|
||||
[2, 22],
|
||||
[2, 21],
|
||||
[2, 20],
|
||||
[2, 17],
|
||||
[2, 13],
|
||||
[2, 8],
|
||||
[2, 7],
|
||||
[2, 5],
|
||||
[2, 1],
|
||||
[1, 11],
|
||||
[1, 7],
|
||||
[1, 6],
|
||||
[1, 1]
|
||||
];
|
||||
|
||||
let actualStops: number[][] = [];
|
||||
for (let i = 0; i < expectedStops.length; i++) {
|
||||
moveWordPartLeft(editor);
|
||||
const pos = editor.getPosition();
|
||||
actualStops.push([pos.lineNumber, pos.column]);
|
||||
}
|
||||
|
||||
assert.deepEqual(actualStops, expectedStops);
|
||||
});
|
||||
test('cursorWordPartLeft - basic', () => {
|
||||
const EXPECTED = [
|
||||
'|start| |line|',
|
||||
'|this|Is|A|Camel|Case|Var| |this|_is|_a|_snake|_case|_var| |THIS|_IS|_CAPS|_SNAKE| |this|_IS|Mixed|Use|',
|
||||
'|end| |line'
|
||||
].join('\n');
|
||||
const [text,] = deserializePipePositions(EXPECTED);
|
||||
const actualStops = testRepeatedActionAndExtractPositions(
|
||||
text,
|
||||
new Position(1000, 1000),
|
||||
ed => cursorWordPartLeft(ed),
|
||||
ed => ed.getPosition(),
|
||||
ed => ed.getPosition().equals(new Position(1, 1))
|
||||
);
|
||||
const actual = serializePipePositions(text, actualStops);
|
||||
assert.deepEqual(actual, EXPECTED);
|
||||
});
|
||||
|
||||
test('move word part right basic', () => {
|
||||
withTestCodeEditor([
|
||||
'start line',
|
||||
'thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse',
|
||||
'end line'
|
||||
], {}, (editor, _) => {
|
||||
editor.setPosition(new Position(1, 1));
|
||||
const expectedStops = [
|
||||
[1, 6],
|
||||
[1, 7],
|
||||
[1, 11],
|
||||
[2, 1],
|
||||
[2, 5],
|
||||
[2, 7],
|
||||
[2, 8],
|
||||
[2, 13],
|
||||
[2, 17],
|
||||
[2, 20],
|
||||
[2, 21],
|
||||
[2, 22],
|
||||
[2, 27],
|
||||
[2, 30],
|
||||
[2, 32],
|
||||
[2, 38],
|
||||
[2, 43],
|
||||
[2, 46],
|
||||
[2, 47],
|
||||
[2, 52],
|
||||
[2, 55],
|
||||
[2, 60],
|
||||
[2, 65],
|
||||
[2, 66],
|
||||
[2, 71],
|
||||
[2, 73],
|
||||
[2, 78],
|
||||
[2, 81],
|
||||
[3, 1],
|
||||
[3, 4],
|
||||
[3, 5],
|
||||
[3, 9]
|
||||
];
|
||||
|
||||
let actualStops: number[][] = [];
|
||||
for (let i = 0; i < expectedStops.length; i++) {
|
||||
moveWordPartRight(editor);
|
||||
const pos = editor.getPosition();
|
||||
actualStops.push([pos.lineNumber, pos.column]);
|
||||
}
|
||||
assert.deepEqual(actualStops, expectedStops);
|
||||
});
|
||||
test('cursorWordPartLeft - issue #53899: whitespace', () => {
|
||||
const EXPECTED = '|myvar| |=| |\'|demonstration| |of| |selection| |with| |space|\'';
|
||||
const [text,] = deserializePipePositions(EXPECTED);
|
||||
const actualStops = testRepeatedActionAndExtractPositions(
|
||||
text,
|
||||
new Position(1000, 1000),
|
||||
ed => cursorWordPartLeft(ed),
|
||||
ed => ed.getPosition(),
|
||||
ed => ed.getPosition().equals(new Position(1, 1))
|
||||
);
|
||||
const actual = serializePipePositions(text, actualStops);
|
||||
assert.deepEqual(actual, EXPECTED);
|
||||
});
|
||||
|
||||
test('delete word part left basic', () => {
|
||||
withTestCodeEditor([
|
||||
' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse'
|
||||
], {}, (editor, _) => {
|
||||
const model = editor.getModel();
|
||||
editor.setPosition(new Position(1, 1000));
|
||||
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixed', '001');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_IS', '002');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this', '003');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE ', '004');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE', '005');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS', '006');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS', '007');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS', '008');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var ', '009');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var', '010');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case', '011');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake', '012');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a', '013');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is', '014');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this', '015');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar ', '016');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar', '017');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamelCase', '018');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsACamel', '019');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIsA', '020');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ thisIs', '021');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ this', '022');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */ ', '023');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 */', '024');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3 ', '025');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-3', '025bis');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5-', '026');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +5', '027');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 +', '028');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3 ', '029');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= 3', '029bis');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+= ', '030');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a+=', '031');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text a', '032');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text ', '033');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some text', '034');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some ', '035');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just some', '036');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just ', '037');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* Just', '038');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /* ', '039');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' /*', '040');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), ' ', '041');
|
||||
deleteWordPartLeft(editor); assert.equal(model.getLineContent(1), '', '042');
|
||||
});
|
||||
test('cursorWordPartLeft - issue #53899: underscores', () => {
|
||||
const EXPECTED = '|myvar| |=| |\'|demonstration|_____of| |selection| |with| |space|\'';
|
||||
const [text,] = deserializePipePositions(EXPECTED);
|
||||
const actualStops = testRepeatedActionAndExtractPositions(
|
||||
text,
|
||||
new Position(1000, 1000),
|
||||
ed => cursorWordPartLeft(ed),
|
||||
ed => ed.getPosition(),
|
||||
ed => ed.getPosition().equals(new Position(1, 1))
|
||||
);
|
||||
const actual = serializePipePositions(text, actualStops);
|
||||
assert.deepEqual(actual, EXPECTED);
|
||||
});
|
||||
|
||||
test('delete word part right basic', () => {
|
||||
withTestCodeEditor([
|
||||
' /* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse'
|
||||
], {}, (editor, _) => {
|
||||
const model = editor.getModel();
|
||||
editor.setPosition(new Position(1, 1));
|
||||
test('cursorWordPartRight - basic', () => {
|
||||
const EXPECTED = [
|
||||
'start| |line|',
|
||||
'|this|Is|A|Camel|Case|Var| |this_|is_|a_|snake_|case_|var| |THIS_|IS_|CAPS_|SNAKE| |this_|IS|Mixed|Use|',
|
||||
'|end| |line|'
|
||||
].join('\n');
|
||||
const [text,] = deserializePipePositions(EXPECTED);
|
||||
const actualStops = testRepeatedActionAndExtractPositions(
|
||||
text,
|
||||
new Position(1, 1),
|
||||
ed => cursorWordPartRight(ed),
|
||||
ed => ed.getPosition(),
|
||||
ed => ed.getPosition().equals(new Position(3, 9))
|
||||
);
|
||||
const actual = serializePipePositions(text, actualStops);
|
||||
assert.deepEqual(actual, EXPECTED);
|
||||
});
|
||||
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), '/* Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '001');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), ' Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '002');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'Just some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '003');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), ' some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '004');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'some text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '005');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), ' text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '006');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'text a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '007');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), ' a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '008');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'a+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '009');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), '+= 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '010');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), ' 3 +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '011');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), ' +5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '012');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), '5-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '013');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), '-3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '014');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), '3 */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '015');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), ' */ thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '016');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), ' thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '017');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'thisIsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '018');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'IsACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '019');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'ACamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '020');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'CamelCaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '021');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'CaseVar this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '022');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'Var this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '023');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), ' this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '024');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'this_is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '025');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'is_a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '026');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'a_snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '027');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'snake_case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '028');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'case_var THIS_IS_CAPS_SNAKE this_ISMixedUse', '029');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'var THIS_IS_CAPS_SNAKE this_ISMixedUse', '030');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), ' THIS_IS_CAPS_SNAKE this_ISMixedUse', '031');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'THIS_IS_CAPS_SNAKE this_ISMixedUse', '032');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'IS_CAPS_SNAKE this_ISMixedUse', '033');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'CAPS_SNAKE this_ISMixedUse', '034');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'SNAKE this_ISMixedUse', '035');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), ' this_ISMixedUse', '036');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'this_ISMixedUse', '037');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'ISMixedUse', '038');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'MixedUse', '039');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), 'Use', '040');
|
||||
deleteWordPartRight(editor); assert.equal(model.getLineContent(1), '', '041');
|
||||
});
|
||||
test('cursorWordPartRight - issue #53899: whitespace', () => {
|
||||
const EXPECTED = 'myvar| |=| |\'|demonstration| |of| |selection| |with| |space|\'|';
|
||||
const [text,] = deserializePipePositions(EXPECTED);
|
||||
const actualStops = testRepeatedActionAndExtractPositions(
|
||||
text,
|
||||
new Position(1, 1),
|
||||
ed => cursorWordPartRight(ed),
|
||||
ed => ed.getPosition(),
|
||||
ed => ed.getPosition().equals(new Position(1, 52))
|
||||
);
|
||||
const actual = serializePipePositions(text, actualStops);
|
||||
assert.deepEqual(actual, EXPECTED);
|
||||
});
|
||||
|
||||
test('cursorWordPartRight - issue #53899: underscores', () => {
|
||||
const EXPECTED = 'myvar| |=| |\'|demonstration_____|of| |selection| |with| |space|\'|';
|
||||
const [text,] = deserializePipePositions(EXPECTED);
|
||||
const actualStops = testRepeatedActionAndExtractPositions(
|
||||
text,
|
||||
new Position(1, 1),
|
||||
ed => cursorWordPartRight(ed),
|
||||
ed => ed.getPosition(),
|
||||
ed => ed.getPosition().equals(new Position(1, 52))
|
||||
);
|
||||
const actual = serializePipePositions(text, actualStops);
|
||||
assert.deepEqual(actual, EXPECTED);
|
||||
});
|
||||
|
||||
test('cursorWordPartRight - issue #53899: second case', () => {
|
||||
const EXPECTED = [
|
||||
';| |--| |1|',
|
||||
'|;| |--| |2|',
|
||||
'|;| |#|3|',
|
||||
'|;| |#|4|'
|
||||
].join('\n');
|
||||
const [text,] = deserializePipePositions(EXPECTED);
|
||||
const actualStops = testRepeatedActionAndExtractPositions(
|
||||
text,
|
||||
new Position(1, 1),
|
||||
ed => cursorWordPartRight(ed),
|
||||
ed => ed.getPosition(),
|
||||
ed => ed.getPosition().equals(new Position(4, 7))
|
||||
);
|
||||
const actual = serializePipePositions(text, actualStops);
|
||||
assert.deepEqual(actual, EXPECTED);
|
||||
});
|
||||
|
||||
test('deleteWordPartLeft - basic', () => {
|
||||
const EXPECTED = '| |/*| |Just| |some| |text| |a|+=| |3| |+|5|-|3| |*/| |this|Is|A|Camel|Case|Var| |this|_is|_a|_snake|_case|_var| |THIS|_IS|_CAPS|_SNAKE| |this|_IS|Mixed|Use';
|
||||
const [text,] = deserializePipePositions(EXPECTED);
|
||||
const actualStops = testRepeatedActionAndExtractPositions(
|
||||
text,
|
||||
new Position(1, 1000),
|
||||
ed => deleteWordPartLeft(ed),
|
||||
ed => ed.getPosition(),
|
||||
ed => ed.getValue().length === 0
|
||||
);
|
||||
const actual = serializePipePositions(text, actualStops);
|
||||
assert.deepEqual(actual, EXPECTED);
|
||||
});
|
||||
|
||||
test('deleteWordPartRight - basic', () => {
|
||||
const EXPECTED = ' |/*| |Just| |some| |text| |a|+=| |3| |+|5|-|3| |*/| |this|Is|A|Camel|Case|Var| |this_|is_|a_|snake_|case_|var| |THIS_|IS_|CAPS_|SNAKE| |this_|IS|Mixed|Use|';
|
||||
const [text,] = deserializePipePositions(EXPECTED);
|
||||
const actualStops = testRepeatedActionAndExtractPositions(
|
||||
text,
|
||||
new Position(1, 1),
|
||||
ed => deleteWordPartRight(ed),
|
||||
ed => new Position(1, text.length - ed.getValue().length + 1),
|
||||
ed => ed.getValue().length === 0
|
||||
);
|
||||
const actual = serializePipePositions(text, actualStops);
|
||||
assert.deepEqual(actual, EXPECTED);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,20 +3,18 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { registerEditorCommand } from 'vs/editor/browser/editorExtensions';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { WordNavigationType, WordPartOperations } from 'vs/editor/common/controller/cursorWordOperations';
|
||||
import { WordCharacterClassifier } from 'vs/editor/common/controller/wordCharacterClassifier';
|
||||
import { DeleteWordCommand, MoveWordCommand } from '../wordOperations/wordOperations';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { DeleteWordCommand, MoveWordCommand } from 'vs/editor/contrib/wordOperations/wordOperations';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
|
||||
export class DeleteWordPartLeft extends DeleteWordCommand {
|
||||
constructor() {
|
||||
@@ -35,7 +33,7 @@ export class DeleteWordPartLeft extends DeleteWordCommand {
|
||||
}
|
||||
|
||||
protected _delete(wordSeparators: WordCharacterClassifier, model: ITextModel, selection: Selection, whitespaceHeuristics: boolean, wordNavigationType: WordNavigationType): Range {
|
||||
let r = WordPartOperations.deleteWordPartLeft(wordSeparators, model, selection, whitespaceHeuristics, wordNavigationType);
|
||||
let r = WordPartOperations.deleteWordPartLeft(wordSeparators, model, selection, whitespaceHeuristics);
|
||||
if (r) {
|
||||
return r;
|
||||
}
|
||||
@@ -60,7 +58,7 @@ export class DeleteWordPartRight extends DeleteWordCommand {
|
||||
}
|
||||
|
||||
protected _delete(wordSeparators: WordCharacterClassifier, model: ITextModel, selection: Selection, whitespaceHeuristics: boolean, wordNavigationType: WordNavigationType): Range {
|
||||
let r = WordPartOperations.deleteWordPartRight(wordSeparators, model, selection, whitespaceHeuristics, wordNavigationType);
|
||||
let r = WordPartOperations.deleteWordPartRight(wordSeparators, model, selection, whitespaceHeuristics);
|
||||
if (r) {
|
||||
return r;
|
||||
}
|
||||
@@ -72,7 +70,7 @@ export class DeleteWordPartRight extends DeleteWordCommand {
|
||||
|
||||
export class WordPartLeftCommand extends MoveWordCommand {
|
||||
protected _move(wordSeparators: WordCharacterClassifier, model: ITextModel, position: Position, wordNavigationType: WordNavigationType): Position {
|
||||
return WordPartOperations.moveWordPartLeft(wordSeparators, model, position, wordNavigationType);
|
||||
return WordPartOperations.moveWordPartLeft(wordSeparators, model, position);
|
||||
}
|
||||
}
|
||||
export class CursorWordPartLeft extends WordPartLeftCommand {
|
||||
@@ -115,7 +113,7 @@ CommandsRegistry.registerCommandAlias('cursorWordPartStartLeftSelect', 'cursorWo
|
||||
|
||||
export class WordPartRightCommand extends MoveWordCommand {
|
||||
protected _move(wordSeparators: WordCharacterClassifier, model: ITextModel, position: Position, wordNavigationType: WordNavigationType): Position {
|
||||
return WordPartOperations.moveWordPartRight(wordSeparators, model, position, wordNavigationType);
|
||||
return WordPartOperations.moveWordPartRight(wordSeparators, model, position);
|
||||
}
|
||||
}
|
||||
export class CursorWordPartRight extends WordPartRightCommand {
|
||||
|
||||
Reference in New Issue
Block a user