mirror of
https://github.com/Microsoft/vscode
synced 2024-10-13 06:48:17 +00:00
parent
6fb482dca1
commit
3a35fae761
|
@ -1,34 +0,0 @@
|
||||||
/*---------------------------------------------------------------------------------------------
|
|
||||||
* 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 * 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 { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||||
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
|
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
|
||||||
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
|
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 { TerminalPanel } from 'vs/workbench/contrib/terminal/browser/terminalPanel';
|
||||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||||
import { TerminalTab } from 'vs/workbench/contrib/terminal/browser/terminalTab';
|
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 { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||||
import { IFileService } from 'vs/platform/files/common/files';
|
import { IFileService } from 'vs/platform/files/common/files';
|
||||||
import { TerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminalInstance';
|
import { TerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminalInstance';
|
||||||
|
@ -86,6 +86,8 @@ export class TerminalService implements ITerminalService {
|
||||||
protected readonly _onRequestAvailableShells = new Emitter<IAvailableShellsRequest>();
|
protected readonly _onRequestAvailableShells = new Emitter<IAvailableShellsRequest>();
|
||||||
public get onRequestAvailableShells(): Event<IAvailableShellsRequest> { return this._onRequestAvailableShells.event; }
|
public get onRequestAvailableShells(): Event<IAvailableShellsRequest> { return this._onRequestAvailableShells.event; }
|
||||||
|
|
||||||
|
private readonly _terminalNativeService: ITerminalNativeService | undefined;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@IContextKeyService private _contextKeyService: IContextKeyService,
|
@IContextKeyService private _contextKeyService: IContextKeyService,
|
||||||
@IPanelService private _panelService: IPanelService,
|
@IPanelService private _panelService: IPanelService,
|
||||||
|
@ -96,20 +98,25 @@ export class TerminalService implements ITerminalService {
|
||||||
@IExtensionService private _extensionService: IExtensionService,
|
@IExtensionService private _extensionService: IExtensionService,
|
||||||
@IFileService private _fileService: IFileService,
|
@IFileService private _fileService: IFileService,
|
||||||
@IRemoteAgentService private _remoteAgentService: IRemoteAgentService,
|
@IRemoteAgentService private _remoteAgentService: IRemoteAgentService,
|
||||||
@ITerminalNativeService private _terminalNativeService: ITerminalNativeService,
|
|
||||||
@IQuickInputService private _quickInputService: IQuickInputService,
|
@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._activeTabIndex = 0;
|
||||||
this._isShuttingDown = false;
|
this._isShuttingDown = false;
|
||||||
this._findState = new FindReplaceState();
|
this._findState = new FindReplaceState();
|
||||||
lifecycleService.onBeforeShutdown(event => event.veto(this._onBeforeShutdown()));
|
lifecycleService.onBeforeShutdown(event => event.veto(this._onBeforeShutdown()));
|
||||||
lifecycleService.onShutdown(() => this._onShutdown());
|
lifecycleService.onShutdown(() => this._onShutdown());
|
||||||
this._terminalNativeService.onOpenFileRequest(e => this._onOpenFileRequest(e));
|
if (this._terminalNativeService) {
|
||||||
this._terminalNativeService.onOsResume(() => this._onOsResume());
|
this._terminalNativeService.onOpenFileRequest(e => this._onOpenFileRequest(e));
|
||||||
|
this._terminalNativeService.onOsResume(() => this._onOsResume());
|
||||||
|
}
|
||||||
this._terminalFocusContextKey = KEYBINDING_CONTEXT_TERMINAL_FOCUS.bindTo(this._contextKeyService);
|
this._terminalFocusContextKey = KEYBINDING_CONTEXT_TERMINAL_FOCUS.bindTo(this._contextKeyService);
|
||||||
this._findWidgetVisible = KEYBINDING_CONTEXT_TERMINAL_FIND_WIDGET_VISIBLE.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.onTabDisposed(tab => this._removeTab(tab));
|
||||||
this.onActiveTabChanged(() => {
|
this.onActiveTabChanged(() => {
|
||||||
const instance = this.getActiveInstance();
|
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.
|
// marker file to get deleted and then focus back to the integrated terminal.
|
||||||
if (request.termProgram === 'vscode' && request.filesToWait) {
|
if (request.termProgram === 'vscode' && request.filesToWait) {
|
||||||
const waitMarkerFileUri = URI.revive(request.filesToWait.waitMarkerFileUri);
|
const waitMarkerFileUri = URI.revive(request.filesToWait.waitMarkerFileUri);
|
||||||
this._terminalNativeService.whenFileDeleted(waitMarkerFileUri).then(() => {
|
this._terminalNativeService?.whenFileDeleted(waitMarkerFileUri).then(() => {
|
||||||
if (this.terminalInstances.length > 0) {
|
if (this.terminalInstances.length > 0) {
|
||||||
const terminal = this.getActiveInstance();
|
const terminal = this.getActiveInstance();
|
||||||
if (terminal) {
|
if (terminal) {
|
||||||
|
@ -533,7 +540,7 @@ export class TerminalService implements ITerminalService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (shellType === WindowsShellType.Wsl) {
|
else if (shellType === WindowsShellType.Wsl) {
|
||||||
if (this._terminalNativeService.getWindowsBuildNumber() >= 17063) {
|
if (this._terminalNativeService && this._terminalNativeService.getWindowsBuildNumber() >= 17063) {
|
||||||
c(this._terminalNativeService.getWslPath(originalPath));
|
c(this._terminalNativeService.getWslPath(originalPath));
|
||||||
} else {
|
} else {
|
||||||
c(originalPath.replace(/\\/g, '/'));
|
c(originalPath.replace(/\\/g, '/'));
|
||||||
|
@ -548,7 +555,7 @@ export class TerminalService implements ITerminalService {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const lowerExecutable = executable.toLowerCase();
|
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))) {
|
(lowerExecutable.indexOf('wsl') !== -1 || (lowerExecutable.indexOf('bash.exe') !== -1 && lowerExecutable.toLowerCase().indexOf('git') === -1))) {
|
||||||
c(this._terminalNativeService.getWslPath(originalPath));
|
c(this._terminalNativeService.getWslPath(originalPath));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -108,7 +108,6 @@ import 'vs/workbench/contrib/webview/browser/webviewService';
|
||||||
import 'vs/workbench/contrib/webview/browser/webviewWorkbenchService';
|
import 'vs/workbench/contrib/webview/browser/webviewWorkbenchService';
|
||||||
|
|
||||||
// Terminal
|
// Terminal
|
||||||
import 'vs/workbench/contrib/terminal/browser/terminalNativeService';
|
|
||||||
import 'vs/workbench/contrib/terminal/browser/terminalInstanceService';
|
import 'vs/workbench/contrib/terminal/browser/terminalInstanceService';
|
||||||
|
|
||||||
// Tasks
|
// Tasks
|
||||||
|
|
Loading…
Reference in a new issue