Skip to content

Commit

Permalink
Add tests for cursor motion detection
Browse files Browse the repository at this point in the history
  • Loading branch information
tshino committed Mar 31, 2022
1 parent 687d163 commit 461f0e6
Showing 1 changed file with 70 additions and 1 deletion.
71 changes: 70 additions & 1 deletion test/suite/cursor_motion_detector.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) ],
Expand Down

0 comments on commit 461f0e6

Please sign in to comment.