提交 3a35fae7 编写于 作者: D Daniel Imms

Remove browser/terminalNativeService

Fixes #81988
上级 6fb482dc
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IOpenFileRequest } from 'vs/platform/windows/common/windows';
import { ITerminalNativeService, LinuxDistro } from 'vs/workbench/contrib/terminal/common/terminal';
import { Emitter, Event } from 'vs/base/common/event';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
export class TerminalNativeService implements ITerminalNativeService {
public _serviceBrand: undefined;
public get linuxDistro(): LinuxDistro { return LinuxDistro.Unknown; }
private readonly _onOpenFileRequest = new Emitter<IOpenFileRequest>();
public get onOpenFileRequest(): Event<IOpenFileRequest> { return this._onOpenFileRequest.event; }
private readonly _onOsResume = new Emitter<void>();
public get onOsResume(): Event<void> { return this._onOsResume.event; }
public whenFileDeleted(): Promise<void> {
throw new Error('Not implemented');
}
public getWslPath(): Promise<string> {
throw new Error('Not implemented');
}
public getWindowsBuildNumber(): number {
throw new Error('Not implemented');
}
}
registerSingleton(ITerminalNativeService, TerminalNativeService, true);
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
import { TERMINAL_PANEL_ID, IShellLaunchConfig, ITerminalConfigHelper, ITerminalNativeService, ISpawnExtHostProcessRequest, IStartExtensionTerminalRequest, IAvailableShellsRequest, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE, KEYBINDING_CONTEXT_TERMINAL_IS_OPEN, ITerminalProcessExtHostProxy, IShellDefinition } from 'vs/workbench/contrib/terminal/common/terminal';
import { TERMINAL_PANEL_ID, IShellLaunchConfig, ITerminalConfigHelper, ITerminalNativeService, ISpawnExtHostProcessRequest, IStartExtensionTerminalRequest, IAvailableShellsRequest, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE, KEYBINDING_CONTEXT_TERMINAL_IS_OPEN, ITerminalProcessExtHostProxy, IShellDefinition, LinuxDistro } from 'vs/workbench/contrib/terminal/common/terminal';
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
......@@ -12,7 +12,7 @@ import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { TerminalPanel } from 'vs/workbench/contrib/terminal/browser/terminalPanel';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { TerminalTab } from 'vs/workbench/contrib/terminal/browser/terminalTab';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IInstantiationService, optional } from 'vs/platform/instantiation/common/instantiation';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { IFileService } from 'vs/platform/files/common/files';
import { TerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminalInstance';
......@@ -86,6 +86,8 @@ export class TerminalService implements ITerminalService {
protected readonly _onRequestAvailableShells = new Emitter<IAvailableShellsRequest>();
public get onRequestAvailableShells(): Event<IAvailableShellsRequest> { return this._onRequestAvailableShells.event; }
private readonly _terminalNativeService: ITerminalNativeService | undefined;
constructor(
@IContextKeyService private _contextKeyService: IContextKeyService,
@IPanelService private _panelService: IPanelService,
......@@ -96,20 +98,25 @@ export class TerminalService implements ITerminalService {
@IExtensionService private _extensionService: IExtensionService,
@IFileService private _fileService: IFileService,
@IRemoteAgentService private _remoteAgentService: IRemoteAgentService,
@ITerminalNativeService private _terminalNativeService: ITerminalNativeService,
@IQuickInputService private _quickInputService: IQuickInputService,
@IConfigurationService private _configurationService: IConfigurationService
@IConfigurationService private _configurationService: IConfigurationService,
@optional(ITerminalNativeService) terminalNativeService: ITerminalNativeService
) {
// @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(event => event.veto(this._onBeforeShutdown()));
lifecycleService.onShutdown(() => this._onShutdown());
if (this._terminalNativeService) {
this._terminalNativeService.onOpenFileRequest(e => this._onOpenFileRequest(e));
this._terminalNativeService.onOsResume(() => this._onOsResume());
}
this._terminalFocusContextKey = KEYBINDING_CONTEXT_TERMINAL_FOCUS.bindTo(this._contextKeyService);
this._findWidgetVisible = KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE.bindTo(this._contextKeyService);
this._configHelper = this._instantiationService.createInstance(TerminalConfigHelper, this._terminalNativeService.linuxDistro);
this._configHelper = this._instantiationService.createInstance(TerminalConfigHelper, this._terminalNativeService?.linuxDistro || LinuxDistro.Unknown);
this.onTabDisposed(tab => this._removeTab(tab));
this.onActiveTabChanged(() => {
const instance = this.getActiveInstance();
......@@ -201,7 +208,7 @@ export class TerminalService implements ITerminalService {
// marker file to get deleted and then focus back to the integrated terminal.
if (request.termProgram === 'vscode' && request.filesToWait) {
const waitMarkerFileUri = URI.revive(request.filesToWait.waitMarkerFileUri);
this._terminalNativeService.whenFileDeleted(waitMarkerFileUri).then(() => {
this._terminalNativeService?.whenFileDeleted(waitMarkerFileUri).then(() => {
if (this.terminalInstances.length > 0) {
const terminal = this.getActiveInstance();
if (terminal) {
......@@ -533,7 +540,7 @@ export class TerminalService implements ITerminalService {
return;
}
else if (shellType === WindowsShellType.Wsl) {
if (this._terminalNativeService.getWindowsBuildNumber() >= 17063) {
if (this._terminalNativeService && this._terminalNativeService.getWindowsBuildNumber() >= 17063) {
c(this._terminalNativeService.getWslPath(originalPath));
} else {
c(originalPath.replace(/\\/g, '/'));
......@@ -548,7 +555,7 @@ export class TerminalService implements ITerminalService {
}
} else {
const lowerExecutable = executable.toLowerCase();
if (this._terminalNativeService.getWindowsBuildNumber() >= 17063 &&
if (this._terminalNativeService && this._terminalNativeService.getWindowsBuildNumber() >= 17063 &&
(lowerExecutable.indexOf('wsl') !== -1 || (lowerExecutable.indexOf('bash.exe') !== -1 && lowerExecutable.toLowerCase().indexOf('git') === -1))) {
c(this._terminalNativeService.getWslPath(originalPath));
return;
......
......@@ -108,7 +108,6 @@ import 'vs/workbench/contrib/webview/browser/webviewService';
import 'vs/workbench/contrib/webview/browser/webviewWorkbenchService';
// Terminal
import 'vs/workbench/contrib/terminal/browser/terminalNativeService';
import 'vs/workbench/contrib/terminal/browser/terminalInstanceService';
// Tasks
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册