diff --git a/test/suite/cursor_motion_detector.test.js b/test/suite/cursor_motion_detector.test.js index 6faee8bb..318c7990 100644 --- a/test/suite/cursor_motion_detector.test.js +++ b/test/suite/cursor_motion_detector.test.js @@ -194,9 +194,78 @@ describe('CursorMotionDetector', () => { expectedLogs: [ MoveRight(1) ] }); }); + + it('should detect implicit motion (split into multi-cursor)', async () => { + testDetection({ + init: [ new vscode.Selection(3, 7, 3, 7) ], + inputs: [ + { predicted: [ new vscode.Selection(3, 7, 3, 7) ] }, + { changed: [ new vscode.Selection(3, 10, 3, 10), new vscode.Selection(3, 12, 3, 12) ] } + ], + expectedLogs: [ Split([ 3, 5 ]) ] + }); + }); + it('should detect implicit motion (split multi to multi)', async () => { + testDetection({ + init: [ + new vscode.Selection(3, 7, 3, 7), + new vscode.Selection(6, 7, 6, 7) + ], + inputs: [ + { predicted: [ + new vscode.Selection(3, 7, 3, 7), + new vscode.Selection(6, 7, 6, 7) + ] }, + { changed: [ + new vscode.Selection(3, 10, 3, 10), new vscode.Selection(3, 12, 3, 12), + new vscode.Selection(6, 10, 6, 10), new vscode.Selection(6, 12, 6, 12) + ] } + ], + expectedLogs: [ Split([ 3, 5 ]) ] + }); + }); + it('should detect implicit motion (split into multi-cursor on different lines) (1)', async () => { + testDetection({ + init: [ new vscode.Selection(3, 7, 3, 7) ], + inputs: [ + { predicted: [ new vscode.Selection(3, 7, 3, 7) ] }, + { changed: [ new vscode.Selection(3, 10, 3, 10), new vscode.Selection(5, 2, 5, 2) ] } + ], + expectedLogs: [ Split2([ 3, 2 ], [0, 2]) ] + }); + }); + it('should detect implicit motion (split into multi-cursor on different lines) (2)', async () => { + testDetection({ + init: [ + new vscode.Selection(3, 7, 3, 7), + new vscode.Selection(6, 7, 6, 7) + ], + inputs: [ + { predicted: [ + new vscode.Selection(3, 7, 3, 7), + new vscode.Selection(6, 7, 6, 7) + ] }, + { changed: [ + new vscode.Selection(4, 2, 4, 2), new vscode.Selection(5, 7, 5, 7), + new vscode.Selection(7, 2, 7, 2), new vscode.Selection(8, 7, 8, 7), + ] } + ], + expectedLogs: [ Split2([ 2, 7 ], [ 1, 2 ]) ] + }); + }); + it('should detect implicit motion (split into multi-cursor with selection)', async () => { + testDetection({ + init: [ new vscode.Selection(3, 7, 3, 7) ], + inputs: [ + { predicted: [ new vscode.Selection(3, 7, 3, 7) ] }, + { changed: [ new vscode.Selection(3, 10, 3, 13), new vscode.Selection(3, 12, 3, 15) ] } + ], + expectedLogs: [ SplitSelect([ 3, 5 ], 3) ] + }); + }); }); - describe('implicit motion', () => { + describe('implicit motion without prediction', () => { it('should detect the unexpected motion of cursor (move to left)', async () => { testDetection({ init: [ new vscode.Selection(3, 6, 3, 6) ],