Path: blob/main/src/vs/editor/contrib/caretOperations/test/browser/moveCarretCommand.test.ts
4780 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js';6import { Selection } from '../../../../common/core/selection.js';7import { MoveCaretCommand } from '../../browser/moveCaretCommand.js';8import { testCommand } from '../../../../test/browser/testCommand.js';91011function testMoveCaretLeftCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {12testCommand(lines, null, selection, (accessor, sel) => new MoveCaretCommand(sel, true), expectedLines, expectedSelection);13}1415function testMoveCaretRightCommand(lines: string[], selection: Selection, expectedLines: string[], expectedSelection: Selection): void {16testCommand(lines, null, selection, (accessor, sel) => new MoveCaretCommand(sel, false), expectedLines, expectedSelection);17}1819suite('Editor Contrib - Move Caret Command', () => {2021ensureNoDisposablesAreLeakedInTestSuite();2223test('move selection to left', function () {24testMoveCaretLeftCommand(25[26'012345'27],28new Selection(1, 3, 1, 5),29[30'023145'31],32new Selection(1, 2, 1, 4)33);34});35test('move selection to right', function () {36testMoveCaretRightCommand(37[38'012345'39],40new Selection(1, 3, 1, 5),41[42'014235'43],44new Selection(1, 4, 1, 6)45);46});47test('move selection to left - from first column - no change', function () {48testMoveCaretLeftCommand(49[50'012345'51],52new Selection(1, 1, 1, 1),53[54'012345'55],56new Selection(1, 1, 1, 1)57);58});59test('move selection to right - from last column - no change', function () {60testMoveCaretRightCommand(61[62'012345'63],64new Selection(1, 5, 1, 7),65[66'012345'67],68new Selection(1, 5, 1, 7)69);70});71});727374