mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-19 16:18:58 +01:00
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { workspace, window, commands, ViewColumn, TextEditorViewColumnChangeEvent, Uri, Selection, Position, CancellationTokenSource, TextEditorSelectionChangeKind, Terminal } from 'vscode';
|
||||
import { workspace, window, commands, ViewColumn, TextEditorViewColumnChangeEvent, Uri, Selection, Position, CancellationTokenSource, TextEditorSelectionChangeKind, Terminal, TerminalDimensionsChangeEvent } from 'vscode';
|
||||
import { join } from 'path';
|
||||
import { closeAllEditors, pathEquals, createRandomFile } from '../utils';
|
||||
|
||||
@@ -695,6 +695,45 @@ suite('window namespace tests', () => {
|
||||
const terminal = window.createTerminal();
|
||||
terminal.show();
|
||||
});
|
||||
|
||||
test('onDidChangeTerminalDimensions should fire when new terminals are created', (done) => {
|
||||
const reg1 = window.onDidChangeTerminalDimensions((event: TerminalDimensionsChangeEvent) => {
|
||||
assert.equal(event.terminal, terminal1);
|
||||
assert.equal(typeof event.dimensions.columns, 'number');
|
||||
assert.equal(typeof event.dimensions.rows, 'number');
|
||||
assert.ok(event.dimensions.columns > 0);
|
||||
assert.ok(event.dimensions.rows > 0);
|
||||
reg1.dispose();
|
||||
let terminal2: Terminal;
|
||||
const reg2 = window.onDidOpenTerminal((newTerminal) => {
|
||||
// THis is guarentees to fire before dimensions change event
|
||||
if (newTerminal !== terminal1) {
|
||||
terminal2 = newTerminal;
|
||||
reg2.dispose();
|
||||
}
|
||||
});
|
||||
let firstCalled = false;
|
||||
let secondCalled = false;
|
||||
const reg3 = window.onDidChangeTerminalDimensions((event: TerminalDimensionsChangeEvent) => {
|
||||
if (event.terminal === terminal1) {
|
||||
// The original terminal should fire dimension change after a split
|
||||
firstCalled = true;
|
||||
} else if (event.terminal !== terminal1) {
|
||||
// The new split terminal should fire dimension change
|
||||
secondCalled = true;
|
||||
}
|
||||
if (firstCalled && secondCalled) {
|
||||
terminal1.dispose();
|
||||
terminal2.dispose();
|
||||
reg3.dispose();
|
||||
done();
|
||||
}
|
||||
});
|
||||
commands.executeCommand('workbench.action.terminal.split');
|
||||
});
|
||||
const terminal1 = window.createTerminal({ name: 'test' });
|
||||
terminal1.show();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user