mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 20:13:32 +01:00
Fix terminals showing up twice in new API
This commit is contained in:
@@ -22,7 +22,12 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
|
||||
) {
|
||||
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostTerminalService);
|
||||
this._toDispose = [];
|
||||
this._toDispose.push(terminalService.onInstanceCreated((terminalInstance) => this._onTerminalOpened(terminalInstance)));
|
||||
this._toDispose.push(terminalService.onInstanceCreated((terminalInstance) => {
|
||||
// Delay this message so the TerminalInstance constructor has a change to finish and
|
||||
// return the ID normally to the extension host. The ID that is passed here will be used
|
||||
// to register non-extension API terminals in the extension host.
|
||||
setTimeout(() => this._onTerminalOpened(terminalInstance), 100);
|
||||
}));
|
||||
this._toDispose.push(terminalService.onInstanceDisposed((terminalInstance) => this._onTerminalDisposed(terminalInstance)));
|
||||
this._toDispose.push(terminalService.onInstanceProcessIdReady((terminalInstance) => this._onTerminalProcessIdReady(terminalInstance)));
|
||||
}
|
||||
|
||||
@@ -20,11 +20,15 @@ export class ExtHostTerminal implements vscode.Terminal {
|
||||
|
||||
constructor(
|
||||
proxy: MainThreadTerminalServiceShape,
|
||||
name?: string
|
||||
name: string = '',
|
||||
id?: number
|
||||
) {
|
||||
this._name = name;
|
||||
this._queuedRequests = [];
|
||||
this._proxy = proxy;
|
||||
this._name = name;
|
||||
if (id) {
|
||||
this._id = id;
|
||||
}
|
||||
this._queuedRequests = [];
|
||||
this._pidPromise = new Promise<number>(c => {
|
||||
this._pidPromiseComplete = c;
|
||||
});
|
||||
@@ -149,9 +153,16 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
|
||||
|
||||
// TOOD: How do we set PID
|
||||
// TODO: Make sure both API terminals and non-API terminals are created correctly
|
||||
// TODO: Ensure the terminal that is opened when first launched gets added, I think it's set before the ext host is ready for it
|
||||
public $acceptTerminalOpened(id: number, name: string): void {
|
||||
let index = this._getTerminalIndexById(id);
|
||||
if (index !== null) {
|
||||
// The terminal has already been created (via createTerminal*), only fire the event
|
||||
this._onDidOpenTerminal.fire(this.terminals[index]);
|
||||
return;
|
||||
}
|
||||
// TODO: Only create a terminal if it doesn't already exist for the ID
|
||||
let terminal = new ExtHostTerminal(this._proxy, name);
|
||||
let terminal = new ExtHostTerminal(this._proxy, name, id);
|
||||
this._terminals.push(terminal);
|
||||
this._onDidOpenTerminal.fire(terminal);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user