Wait for terminal data before using terminal.selection APIs

This commit is contained in:
Daniel Imms 2023-07-19 11:14:31 -07:00
parent 471490656d
commit 31b9e9aa9b
No known key found for this signature in database
GPG key ID: E5CF412B63651C69

View file

@ -357,6 +357,13 @@ 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();
@ -364,6 +371,13 @@ import { assertNoRpc, poll } from '../utils';
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');