Skip to content

Commit

Permalink
test: get editor selection at thenable callback function
Browse files Browse the repository at this point in the history
  • Loading branch information
waynewaynetsai committed Jul 11, 2021
1 parent 05cbeab commit a838b76
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/mode/modeVisual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1743,15 +1743,15 @@ suite('Mode Visual', () => {
await modeHandler.handleMultipleKeyEvents(['i', 'h', 'e', 'l', 'l', 'o']);
await modeHandler.handleMultipleKeyEvents(['<Esc>', 'g', 'g', 'v', 'e']);

const selection = modeHandler.vimState.editor.selection;

/**
* Since `vscode.commands.executeCommand` api's returned thenable object doesn't works well with async/await,
* we invoke assert function at thenable's callback function directly.
*/
vscode.commands.executeCommand('vim.switchToInsertModeSelection').then((_) => {
assert.strictEqual(modeHandler.currentMode, Mode.Insert, 'switch to insert mode');

const selection = modeHandler.vimState.editor.selection;

assert.strictEqual(selection.start.character, 0);
assert.strictEqual(selection.start.line, 0);
assert.strictEqual(selection.end.character, 5);
Expand All @@ -1776,11 +1776,11 @@ suite('Mode Visual', () => {
]);
await modeHandler.handleMultipleKeyEvents(['<Esc>', 'g', 'g', 'g', 'b', 'g', 'b']);

const selection = modeHandler.vimState.editor.selections;

vscode.commands.executeCommand('vim.switchToInsertModeSelection').then((_) => {
assert.strictEqual(modeHandler.currentMode, Mode.Insert, 'switch to insert mode');

const selection = modeHandler.vimState.editor.selections;

assert.strictEqual(selection[0].start.character, 0);
assert.strictEqual(selection[0].start.line, 0);
assert.strictEqual(selection[0].end.character, 5);
Expand Down

0 comments on commit a838b76

Please sign in to comment.