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

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { DisposableStore, Disposable } from 'vs/base/common/lifecycle';
import { IShellLaunchConfig, ITerminalProcessExtHostProxy, ISpawnExtHostProcessRequest, ITerminalDimensions, EXT_HOST_CREATION_DELAY, IAvailableShellsRequest, IDefaultShellAndArgsRequest, IStartExtensionTerminalRequest } from 'vs/workbench/contrib/terminal/common/terminal';
import { IShellLaunchConfig, ITerminalProcessExtHostProxy, ISpawnExtHostProcessRequest, ITerminalDimensions, IAvailableShellsRequest, IDefaultShellAndArgsRequest, IStartExtensionTerminalRequest } from 'vs/workbench/contrib/terminal/common/terminal';
import { ExtHostContext, ExtHostTerminalServiceShape, MainThreadTerminalServiceShape, MainContext, IExtHostContext, IShellLaunchConfigDto, TerminalLaunchConfig, ITerminalDimensionsDto } from 'vs/workbench/api/common/extHost.protocol';
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { URI } from 'vs/base/common/uri';
@@ -36,13 +36,8 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
// ITerminalService listeners
this._toDispose.add(_terminalService.onInstanceCreated((instance) => {
// Delay this message so the TerminalInstance constructor has a chance 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(instance);
this._onInstanceDimensionsChanged(instance);
}, EXT_HOST_CREATION_DELAY);
this._onTerminalOpened(instance);
this._onInstanceDimensionsChanged(instance);
}));
this._toDispose.add(_terminalService.onInstanceDisposed(instance => this._onTerminalDisposed(instance)));