|
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
6 | 6 | import { deepStrictEqual, doesNotThrow, equal, ok, strictEqual, throws } from 'assert'; |
7 | | -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'; |
| 7 | +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'; |
8 | 8 | import { assertNoRpc, poll } from '../utils'; |
9 | 9 |
|
10 | 10 | // Disable terminal tests: |
@@ -347,6 +347,45 @@ import { assertNoRpc, poll } from '../utils'; |
347 | 347 | }); |
348 | 348 | }); |
349 | 349 |
|
| 350 | + suite('selection', () => { |
| 351 | + test('should be undefined immediately after creation', async () => { |
| 352 | + const terminal = window.createTerminal({ name: 'selection test' }); |
| 353 | + terminal.show(); |
| 354 | + equal(terminal.selection, undefined); |
| 355 | + terminal.dispose(); |
| 356 | + }); |
| 357 | + test('should be defined after selecting all content', async () => { |
| 358 | + const terminal = window.createTerminal({ name: 'selection test' }); |
| 359 | + terminal.show(); |
| 360 | + // Wait for some terminal data |
| 361 | + await new Promise<void>(r => { |
| 362 | + const disposable = window.onDidWriteTerminalData(() => { |
| 363 | + disposable.dispose(); |
| 364 | + r(); |
| 365 | + }); |
| 366 | + }); |
| 367 | + await commands.executeCommand('workbench.action.terminal.selectAll'); |
| 368 | + await poll<void>(() => Promise.resolve(), () => terminal.selection !== undefined, 'selection should be defined'); |
| 369 | + terminal.dispose(); |
| 370 | + }); |
| 371 | + test('should be undefined after clearing a selection', async () => { |
| 372 | + const terminal = window.createTerminal({ name: 'selection test' }); |
| 373 | + terminal.show(); |
| 374 | + // Wait for some terminal data |
| 375 | + await new Promise<void>(r => { |
| 376 | + const disposable = window.onDidWriteTerminalData(() => { |
| 377 | + disposable.dispose(); |
| 378 | + r(); |
| 379 | + }); |
| 380 | + }); |
| 381 | + await commands.executeCommand('workbench.action.terminal.selectAll'); |
| 382 | + await poll<void>(() => Promise.resolve(), () => terminal.selection !== undefined, 'selection should be defined'); |
| 383 | + await commands.executeCommand('workbench.action.terminal.clearSelection'); |
| 384 | + await poll<void>(() => Promise.resolve(), () => terminal.selection === undefined, 'selection should not be defined'); |
| 385 | + terminal.dispose(); |
| 386 | + }); |
| 387 | + }); |
| 388 | + |
350 | 389 | suite('window.onDidWriteTerminalData', () => { |
351 | 390 | test('should listen to all future terminal data events', (done) => { |
352 | 391 | const openEvents: string[] = []; |
|
0 commit comments