Add terminal selection API

Part of #188173
This commit is contained in:
Daniel Imms
2023-07-18 09:47:46 -07:00
parent c780d0dfef
commit 99e31ae297
9 changed files with 62 additions and 2 deletions
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { deepStrictEqual, doesNotThrow, equal, ok, strictEqual, throws } from 'assert';
import { ConfigurationTarget, Disposable, env, EnvironmentVariableCollection, EnvironmentVariableMutator, EnvironmentVariableMutatorOptions, EnvironmentVariableMutatorType, EnvironmentVariableScope, EventEmitter, ExtensionContext, extensions, ExtensionTerminalOptions, Pseudoterminal, Terminal, TerminalDimensions, TerminalExitReason, TerminalOptions, TerminalState, UIKind, Uri, window, workspace } from 'vscode';
import { commands, ConfigurationTarget, Disposable, env, EnvironmentVariableCollection, EnvironmentVariableMutator, EnvironmentVariableMutatorOptions, EnvironmentVariableMutatorType, EnvironmentVariableScope, EventEmitter, ExtensionContext, extensions, ExtensionTerminalOptions, Pseudoterminal, Terminal, TerminalDimensions, TerminalExitReason, TerminalOptions, TerminalState, UIKind, Uri, window, workspace } from 'vscode';
import { assertNoRpc, poll } from '../utils';
// Disable terminal tests:
@@ -347,6 +347,27 @@ import { assertNoRpc, poll } from '../utils';
});
});
suite('selection', () => {
test('should be undefined immediately after creation', async () => {
const terminal = window.createTerminal({ name: 'bg', hideFromUser: true });
equal(terminal.selection, undefined);
terminal.dispose();
});
test('should be defined after selecting all content', async () => {
const terminal = window.createTerminal({ name: 'bg', hideFromUser: true });
await commands.executeCommand('workbench.action.terminal.selectAll');
// TODO: Need to poll?
terminal.dispose();
});
test('should be undefined after clearing a selection', async () => {
const terminal = window.createTerminal({ name: 'bg', hideFromUser: true });
await commands.executeCommand('workbench.action.terminal.selectAll');
// TODO: Need to poll?
await commands.executeCommand('workbench.action.terminal.clearSelection');
terminal.dispose();
});
});
suite('window.onDidWriteTerminalData', () => {
test('should listen to all future terminal data events', (done) => {
const openEvents: string[] = [];