Removing EXT_HOST_CREATION_DELAY hacks

This one was a bit tricky to figure out what was going on, but this is how it
was working before: Terminals that use extension processes calls
$createTerminal from the ext host, this returns a promise with an ID that gets
returned asynchronously after the process has been setup (ie. an ext host process
proxy was created).

The reason we needed the timeout was because the process initialization is async
as we need a layout to occur so that we have the dimensions of the terminal to
give to the process. The fix could have been setTimeout(..., 0) as well but that
feels hacky as well, the fix in this commit is to pipe an event through from
the process manager which is the actual time when we are good to start telling
ext hosts are the new terminals.

Fixes #77655
This commit is contained in:
Daniel Imms
2019-10-25 12:56:27 -07:00
parent 74a46b0780
commit 2b61a8817b
7 changed files with 42 additions and 38 deletions

View File

@@ -9,7 +9,7 @@ import { ExtHostTerminalServiceShape, MainContext, MainThreadTerminalServiceShap
import { ExtHostConfigProvider } from 'vs/workbench/api/common/extHostConfiguration';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { URI, UriComponents } from 'vs/base/common/uri';
import { EXT_HOST_CREATION_DELAY, ITerminalChildProcess, ITerminalDimensions } from 'vs/workbench/contrib/terminal/common/terminal';
import { ITerminalChildProcess, ITerminalDimensions } from 'vs/workbench/contrib/terminal/common/terminal';
import { timeout } from 'vs/base/common/async';
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { TerminalDataBufferer } from 'vs/workbench/contrib/terminal/common/terminalDataBuffering';
@@ -412,22 +412,6 @@ export abstract class BaseExtHostTerminalService implements IExtHostTerminalServ
}
}
public performTerminalIdAction(id: number, callback: (terminal: ExtHostTerminal) => void): void {
// TODO: Use await this._getTerminalByIdEventually(id);
let terminal = this._getTerminalById(id);
if (terminal) {
callback(terminal);
} else {
// Retry one more time in case the terminal has not yet been initialized.
setTimeout(() => {
terminal = this._getTerminalById(id);
if (terminal) {
callback(terminal);
}
}, EXT_HOST_CREATION_DELAY * 2);
}
}
public async $startExtensionTerminal(id: number, initialDimensions: ITerminalDimensionsDto | undefined): Promise<void> {
// Make sure the ExtHostTerminal exists so onDidOpenTerminal has fired before we call
// Pseudoterminal.start