Merge from vscode ad407028575a77ea387eb7cc219b323dc017b686

This commit is contained in:
ADS Merger
2020-08-22 06:06:52 +00:00
committed by Anthony Dresser
parent 404260b8a0
commit 4ad73d381c
480 changed files with 14360 additions and 14122 deletions

View File

@@ -4,17 +4,17 @@
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
import { TERMINAL_VIEW_ID, IShellLaunchConfig, ITerminalConfigHelper, ITerminalNativeService, ISpawnExtHostProcessRequest, IStartExtensionTerminalRequest, IAvailableShellsRequest, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_VISIBLE, KEYBINDING_CONTEXT_TERMINAL_IS_OPEN, ITerminalProcessExtHostProxy, IShellDefinition, LinuxDistro, KEYBINDING_CONTEXT_TERMINAL_SHELL_TYPE, ITerminalLaunchError } from 'vs/workbench/contrib/terminal/common/terminal';
import { TERMINAL_VIEW_ID, IShellLaunchConfig, ITerminalConfigHelper, ISpawnExtHostProcessRequest, IStartExtensionTerminalRequest, IAvailableShellsRequest, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_VISIBLE, KEYBINDING_CONTEXT_TERMINAL_IS_OPEN, ITerminalProcessExtHostProxy, IShellDefinition, LinuxDistro, KEYBINDING_CONTEXT_TERMINAL_SHELL_TYPE, ITerminalLaunchError, ITerminalNativeWindowsDelegate } from 'vs/workbench/contrib/terminal/common/terminal';
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { TerminalViewPane } from 'vs/workbench/contrib/terminal/browser/terminalView';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { TerminalTab } from 'vs/workbench/contrib/terminal/browser/terminalTab';
import { IInstantiationService, optional } from 'vs/platform/instantiation/common/instantiation';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { TerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminalInstance';
import { ITerminalService, ITerminalInstance, ITerminalTab, TerminalShellType, WindowsShellType, TerminalLinkHandlerCallback, LINK_INTERCEPT_THRESHOLD, ITerminalExternalLinkProvider } from 'vs/workbench/contrib/terminal/browser/terminal';
import { ITerminalService, ITerminalInstance, ITerminalTab, TerminalShellType, WindowsShellType, ITerminalExternalLinkProvider } from 'vs/workbench/contrib/terminal/browser/terminal';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminalConfigHelper';
import { IQuickInputService, IQuickPickItem, IPickOptions } from 'vs/platform/quickinput/common/quickInput';
@@ -50,7 +50,6 @@ export class TerminalService implements ITerminalService {
private _findState: FindReplaceState;
private _extHostsReady: { [authority: string]: IExtHostReadyEntry | undefined } = {};
private _activeTabIndex: number;
private _linkHandlers: { [key: string]: TerminalLinkHandlerCallback } = {};
private _linkProviders: Set<ITerminalExternalLinkProvider> = new Set();
private _linkProviderDisposables: Map<ITerminalExternalLinkProvider, IDisposable[]> = new Map();
@@ -60,6 +59,7 @@ export class TerminalService implements ITerminalService {
private _configHelper: TerminalConfigHelper;
private _terminalContainer: HTMLElement | undefined;
private _nativeWindowsDelegate: ITerminalNativeWindowsDelegate | undefined;
public get configHelper(): ITerminalConfigHelper { return this._configHelper; }
@@ -92,8 +92,6 @@ export class TerminalService implements ITerminalService {
private readonly _onRequestAvailableShells = new Emitter<IAvailableShellsRequest>();
public get onRequestAvailableShells(): Event<IAvailableShellsRequest> { return this._onRequestAvailableShells.event; }
private readonly _terminalNativeService: ITerminalNativeService | undefined;
constructor(
@IContextKeyService private _contextKeyService: IContextKeyService,
@IWorkbenchLayoutService private _layoutService: IWorkbenchLayoutService,
@@ -105,34 +103,17 @@ export class TerminalService implements ITerminalService {
@IQuickInputService private _quickInputService: IQuickInputService,
@IConfigurationService private _configurationService: IConfigurationService,
@IViewsService private _viewsService: IViewsService,
@IViewDescriptorService private readonly _viewDescriptorService: IViewDescriptorService,
// HACK: Ideally TerminalNativeService would depend on TerminalService and inject the
// additional native functionality into it.
@optional(ITerminalNativeService) terminalNativeService: ITerminalNativeService
@IViewDescriptorService private readonly _viewDescriptorService: IViewDescriptorService
) {
// @optional could give undefined and properly typing it breaks service registration
this._terminalNativeService = terminalNativeService as ITerminalNativeService | undefined;
this._activeTabIndex = 0;
this._isShuttingDown = false;
this._findState = new FindReplaceState();
lifecycleService.onBeforeShutdown(async event => event.veto(this._onBeforeShutdown()));
lifecycleService.onShutdown(() => this._onShutdown());
if (this._terminalNativeService) {
this._terminalNativeService.onRequestFocusActiveInstance(() => {
if (this.terminalInstances.length > 0) {
const terminal = this.getActiveInstance();
if (terminal) {
terminal.focus();
}
}
});
this._terminalNativeService.onOsResume(() => this._onOsResume());
}
this._terminalFocusContextKey = KEYBINDING_CONTEXT_TERMINAL_FOCUS.bindTo(this._contextKeyService);
this._terminalShellTypeContextKey = KEYBINDING_CONTEXT_TERMINAL_SHELL_TYPE.bindTo(this._contextKeyService);
this._findWidgetVisible = KEYBINDING_CONTEXT_TERMINAL_FIND_VISIBLE.bindTo(this._contextKeyService);
this._configHelper = this._instantiationService.createInstance(TerminalConfigHelper, this._terminalNativeService?.linuxDistro || LinuxDistro.Unknown);
this._configHelper = this._instantiationService.createInstance(TerminalConfigHelper);
this.onTabDisposed(tab => this._removeTab(tab));
this.onActiveTabChanged(() => {
const instance = this.getActiveInstance();
@@ -143,6 +124,14 @@ export class TerminalService implements ITerminalService {
this._handleContextKeys();
}
public setNativeWindowsDelegate(delegate: ITerminalNativeWindowsDelegate): void {
this._nativeWindowsDelegate = delegate;
}
public setLinuxDistro(linuxDistro: LinuxDistro): void {
this._configHelper.setLinuxDistro(linuxDistro);
}
private _handleContextKeys(): void {
const terminalIsOpenContext = KEYBINDING_CONTEXT_TERMINAL_IS_OPEN.bindTo(this._contextKeyService);
@@ -226,14 +215,6 @@ export class TerminalService implements ITerminalService {
this.terminalInstances.forEach(instance => instance.dispose(true));
}
private _onOsResume(): void {
const activeTab = this.getActiveTab();
if (!activeTab) {
return;
}
activeTab.terminalInstances.forEach(instance => instance.forceRedraw());
}
public getTabLabels(): string[] {
return this._terminalTabs.filter(tab => tab.terminalInstances.length > 0).map((tab, index) => `${index + 1}: ${tab.title ? tab.title : ''}`);
}
@@ -428,50 +409,6 @@ export class TerminalService implements ITerminalService {
instance.addDisposable(instance.onDimensionsChanged(() => this._onInstanceDimensionsChanged.fire(instance)));
instance.addDisposable(instance.onMaximumDimensionsChanged(() => this._onInstanceMaximumDimensionsChanged.fire(instance)));
instance.addDisposable(instance.onFocus(this._onActiveInstanceChanged.fire, this._onActiveInstanceChanged));
instance.addDisposable(instance.onBeforeHandleLink(async e => {
// No link handlers have been registered
const keys = Object.keys(this._linkHandlers);
if (keys.length === 0) {
e.resolve(false);
return;
}
// Fire each link interceptor and wait for either a true, all false or the cancel time
let resolved = false;
const promises: Promise<boolean>[] = [];
const timeout = setTimeout(() => {
resolved = true;
e.resolve(false);
}, LINK_INTERCEPT_THRESHOLD);
for (let i = 0; i < keys.length; i++) {
const p = this._linkHandlers[keys[i]](e);
p.then(handled => {
if (!resolved && handled) {
resolved = true;
clearTimeout(timeout);
e.resolve(true);
}
});
promises.push(p);
}
await Promise.all(promises);
if (!resolved) {
resolved = true;
clearTimeout(timeout);
e.resolve(false);
}
}));
}
public addLinkHandler(key: string, callback: TerminalLinkHandlerCallback): IDisposable {
this._linkHandlers[key] = callback;
return {
dispose: () => {
if (this._linkHandlers[key] === callback) {
delete this._linkHandlers[key];
}
}
};
}
public registerLinkProvider(linkProvider: ITerminalExternalLinkProvider): IDisposable {
@@ -588,8 +525,8 @@ export class TerminalService implements ITerminalService {
return;
}
else if (shellType === WindowsShellType.Wsl) {
if (this._terminalNativeService && this._terminalNativeService.getWindowsBuildNumber() >= 17063) {
c(this._terminalNativeService.getWslPath(originalPath));
if (this._nativeWindowsDelegate && this._nativeWindowsDelegate.getWindowsBuildNumber() >= 17063) {
c(this._nativeWindowsDelegate.getWslPath(originalPath));
} else {
c(originalPath.replace(/\\/g, '/'));
}
@@ -603,9 +540,9 @@ export class TerminalService implements ITerminalService {
}
} else {
const lowerExecutable = executable.toLowerCase();
if (this._terminalNativeService && this._terminalNativeService.getWindowsBuildNumber() >= 17063 &&
if (this._nativeWindowsDelegate && this._nativeWindowsDelegate.getWindowsBuildNumber() >= 17063 &&
(lowerExecutable.indexOf('wsl') !== -1 || (lowerExecutable.indexOf('bash.exe') !== -1 && lowerExecutable.toLowerCase().indexOf('git') === -1))) {
c(this._terminalNativeService.getWslPath(originalPath));
c(this._nativeWindowsDelegate.getWslPath(originalPath));
return;
} else if (hasSpace) {
c('"' + originalPath + '"');