Skip to content

Commit

Permalink
Wait for terminal data before using terminal.selection APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyriar committed Jul 19, 2023
1 parent 4714906 commit 31b9e9a
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,27 @@ import { assertNoRpc, poll } from '../utils';
test('should be defined after selecting all content', async () => {
const terminal = window.createTerminal({ name: 'selection test' });
terminal.show();
// Wait for some terminal data
await new Promise<void>(r => {
const disposable = window.onDidWriteTerminalData(() => {
disposable.dispose();
r();
});
});
await commands.executeCommand('workbench.action.terminal.selectAll');
await poll<void>(() => Promise.resolve(), () => terminal.selection !== undefined, 'selection should be defined');
terminal.dispose();
});
test('should be undefined after clearing a selection', async () => {
const terminal = window.createTerminal({ name: 'selection test' });
terminal.show();
// Wait for some terminal data
await new Promise<void>(r => {
const disposable = window.onDidWriteTerminalData(() => {
disposable.dispose();
r();
});
});
await commands.executeCommand('workbench.action.terminal.selectAll');
await poll<void>(() => Promise.resolve(), () => terminal.selection !== undefined, 'selection should be defined');
await commands.executeCommand('workbench.action.terminal.clearSelection');
Expand Down

0 comments on commit 31b9e9a

Please sign in to comment.