Get remote profiles working
This commit is contained in:
parent
dd54e2b24a
commit
1816095148
|
@ -86,7 +86,6 @@ import { ChecksumService } from 'vs/platform/checksum/node/checksumService';
|
||||||
import { CustomEndpointTelemetryService } from 'vs/platform/telemetry/node/customEndpointTelemetryService';
|
import { CustomEndpointTelemetryService } from 'vs/platform/telemetry/node/customEndpointTelemetryService';
|
||||||
import { URI } from 'vs/base/common/uri';
|
import { URI } from 'vs/base/common/uri';
|
||||||
import { joinPath } from 'vs/base/common/resources';
|
import { joinPath } from 'vs/base/common/resources';
|
||||||
import { registerTerminalPlatformConfiguration } from 'vs/platform/terminal/common/terminalPlatformConfiguration';
|
|
||||||
|
|
||||||
class SharedProcessMain extends Disposable {
|
class SharedProcessMain extends Disposable {
|
||||||
|
|
||||||
|
@ -116,7 +115,6 @@ class SharedProcessMain extends Disposable {
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
registerUserDataSyncConfiguration();
|
registerUserDataSyncConfiguration();
|
||||||
registerTerminalPlatformConfiguration();
|
|
||||||
|
|
||||||
instantiationService.invokeFunction(accessor => {
|
instantiationService.invokeFunction(accessor => {
|
||||||
const logService = accessor.get(ILogService);
|
const logService = accessor.get(ILogService);
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { IGetTerminalLayoutInfoArgs, IProcessDetails, IPtyHostProcessReplayEvent
|
||||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||||
import { detectAvailableProfiles } from 'vs/platform/terminal/node/terminalProfiles';
|
import { detectAvailableProfiles } from 'vs/platform/terminal/node/terminalProfiles';
|
||||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||||
|
import { registerTerminalPlatformConfiguration } from 'vs/platform/terminal/common/terminalPlatformConfiguration';
|
||||||
|
|
||||||
enum Constants {
|
enum Constants {
|
||||||
MaxRestarts = 5
|
MaxRestarts = 5
|
||||||
|
@ -77,9 +78,6 @@ export class PtyHostService extends Disposable implements IPtyService {
|
||||||
private readonly _onProcessOrphanQuestion = this._register(new Emitter<{ id: number }>());
|
private readonly _onProcessOrphanQuestion = this._register(new Emitter<{ id: number }>());
|
||||||
readonly onProcessOrphanQuestion = this._onProcessOrphanQuestion.event;
|
readonly onProcessOrphanQuestion = this._onProcessOrphanQuestion.event;
|
||||||
|
|
||||||
// TODO: Event for requesting variable resolving, track via id - this will be a round trip but
|
|
||||||
// seems like the only reasonable way to do this
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
||||||
@ILogService private readonly _logService: ILogService,
|
@ILogService private readonly _logService: ILogService,
|
||||||
|
@ -87,6 +85,10 @@ export class PtyHostService extends Disposable implements IPtyService {
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
// Platform configuration is required on the process running the pty host (shared process or
|
||||||
|
// remote server).
|
||||||
|
registerTerminalPlatformConfiguration();
|
||||||
|
|
||||||
this._register(toDisposable(() => this._disposePtyHost()));
|
this._register(toDisposable(() => this._disposePtyHost()));
|
||||||
|
|
||||||
[this._client, this._proxy] = this._startPtyHost();
|
[this._client, this._proxy] = this._startPtyHost();
|
||||||
|
@ -218,16 +220,8 @@ export class PtyHostService extends Disposable implements IPtyService {
|
||||||
return this._proxy.getDefaultSystemShell(osOverride);
|
return this._proxy.getDefaultSystemShell(osOverride);
|
||||||
}
|
}
|
||||||
async getProfiles(includeDetectedProfiles: boolean = false): Promise<ITerminalProfile[]> {
|
async getProfiles(includeDetectedProfiles: boolean = false): Promise<ITerminalProfile[]> {
|
||||||
// return detectAvailableProfiles(configuredProfilesOnly, safeConfigProvider, undefined, this._logService, await this._variableResolverPromise, this._lastActiveWorkspace);
|
|
||||||
// const variableResolver: IConfigurationResolverService {
|
|
||||||
// resolveAsync(folder: IWorkspaceFolder | undefined, value: string): Promise<string> {
|
|
||||||
// }
|
|
||||||
// } as any;
|
|
||||||
// TODO: invert config only arg
|
// TODO: invert config only arg
|
||||||
const r = await detectAvailableProfiles(!includeDetectedProfiles, this._buildSafeConfigProvider(), undefined, this._logService, this._resolveVariables.bind(this));
|
return detectAvailableProfiles(!includeDetectedProfiles, this._buildSafeConfigProvider(), undefined, this._logService, this._resolveVariables.bind(this));
|
||||||
this._logService.info('profiles', r);
|
|
||||||
return r;
|
|
||||||
// return this._proxy.getProfiles?.(includeDetectedProfiles) || [];
|
|
||||||
}
|
}
|
||||||
getEnvironment(): Promise<IProcessEnvironment> {
|
getEnvironment(): Promise<IProcessEnvironment> {
|
||||||
return this._proxy.getEnvironment();
|
return this._proxy.getEnvironment();
|
||||||
|
|
|
@ -42,7 +42,6 @@ export function detectAvailableProfiles(
|
||||||
workspaceFolder
|
workspaceFolder
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
console.log('config provider result', safeConfigProvider(`terminal.integrated.profiles.${isMacintosh ? 'osx' : 'linux'}`));
|
|
||||||
return detectAvailableUnixProfiles(
|
return detectAvailableUnixProfiles(
|
||||||
fsProvider,
|
fsProvider,
|
||||||
logService,
|
logService,
|
||||||
|
@ -154,12 +153,7 @@ async function transformToTerminalProfiles(entries: IterableIterator<[string, IT
|
||||||
icon = profile.icon;
|
icon = profile.icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
// const paths = originalPaths.slice();
|
|
||||||
|
|
||||||
const paths = (await variableResolver?.(originalPaths)) || originalPaths.slice();
|
const paths = (await variableResolver?.(originalPaths)) || originalPaths.slice();
|
||||||
// for (let i = 0; i < paths.length; i++) {
|
|
||||||
// paths[i] = await variableResolver?.resolveAsync(workspaceFolder, paths[i]) || paths[i];
|
|
||||||
// }
|
|
||||||
const validatedProfile = await validateProfilePaths(profileName, defaultProfileName, paths, fsProvider, args, profile.env, profile.overrideName, profile.isAutoDetected, logService);
|
const validatedProfile = await validateProfilePaths(profileName, defaultProfileName, paths, fsProvider, args, profile.env, profile.overrideName, profile.isAutoDetected, logService);
|
||||||
if (validatedProfile) {
|
if (validatedProfile) {
|
||||||
validatedProfile.isAutoDetected = profile.isAutoDetected;
|
validatedProfile.isAutoDetected = profile.isAutoDetected;
|
||||||
|
@ -290,8 +284,6 @@ async function detectAvailableUnixProfiles(
|
||||||
|
|
||||||
applyConfigProfilesToMap(configProfiles, detectedProfiles);
|
applyConfigProfilesToMap(configProfiles, detectedProfiles);
|
||||||
|
|
||||||
console.log('detected', detectedProfiles);
|
|
||||||
|
|
||||||
return await transformToTerminalProfiles(detectedProfiles.entries(), defaultProfileName, fsProvider, logService, variableResolver, workspaceFolder);
|
return await transformToTerminalProfiles(detectedProfiles.entries(), defaultProfileName, fsProvider, logService, variableResolver, workspaceFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,9 @@
|
||||||
import { Emitter } from 'vs/base/common/event';
|
import { Emitter } from 'vs/base/common/event';
|
||||||
import { Disposable } from 'vs/base/common/lifecycle';
|
import { Disposable } from 'vs/base/common/lifecycle';
|
||||||
import { revive } from 'vs/base/common/marshalling';
|
import { revive } from 'vs/base/common/marshalling';
|
||||||
|
import { Schemas } from 'vs/base/common/network';
|
||||||
import { IProcessEnvironment, OperatingSystem } from 'vs/base/common/platform';
|
import { IProcessEnvironment, OperatingSystem } from 'vs/base/common/platform';
|
||||||
|
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||||
import { URI } from 'vs/base/common/uri';
|
import { URI } from 'vs/base/common/uri';
|
||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||||
|
@ -14,11 +16,14 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||||
import { ILogService } from 'vs/platform/log/common/log';
|
import { ILogService } from 'vs/platform/log/common/log';
|
||||||
import { INotificationHandle, INotificationService, IPromptChoice, Severity } from 'vs/platform/notification/common/notification';
|
import { INotificationHandle, INotificationService, IPromptChoice, Severity } from 'vs/platform/notification/common/notification';
|
||||||
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
|
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
|
||||||
import { IShellLaunchConfig, IShellLaunchConfigDto, ITerminalChildProcess, ITerminalProfile, ITerminalsLayoutInfo, ITerminalsLayoutInfoById } from 'vs/platform/terminal/common/terminal';
|
import { IRequestResolveVariablesEvent, IShellLaunchConfig, IShellLaunchConfigDto, ITerminalChildProcess, ITerminalProfile, ITerminalsLayoutInfo, ITerminalsLayoutInfoById } from 'vs/platform/terminal/common/terminal';
|
||||||
|
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||||
import { RemotePty } from 'vs/workbench/contrib/terminal/browser/remotePty';
|
import { RemotePty } from 'vs/workbench/contrib/terminal/browser/remotePty';
|
||||||
import { IRemoteTerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
|
import { IRemoteTerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||||
import { ICompleteTerminalConfiguration, RemoteTerminalChannelClient, REMOTE_TERMINAL_CHANNEL_NAME } from 'vs/workbench/contrib/terminal/common/remoteTerminalChannel';
|
import { ICompleteTerminalConfiguration, RemoteTerminalChannelClient, REMOTE_TERMINAL_CHANNEL_NAME } from 'vs/workbench/contrib/terminal/common/remoteTerminalChannel';
|
||||||
import { IRemoteTerminalAttachTarget, ITerminalConfigHelper } from 'vs/workbench/contrib/terminal/common/terminal';
|
import { IRemoteTerminalAttachTarget, ITerminalConfigHelper } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||||
|
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
|
||||||
|
import { IHistoryService } from 'vs/workbench/services/history/common/history';
|
||||||
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
||||||
|
|
||||||
export class RemoteTerminalService extends Disposable implements IRemoteTerminalService {
|
export class RemoteTerminalService extends Disposable implements IRemoteTerminalService {
|
||||||
|
@ -34,6 +39,8 @@ export class RemoteTerminalService extends Disposable implements IRemoteTerminal
|
||||||
readonly onPtyHostResponsive = this._onPtyHostResponsive.event;
|
readonly onPtyHostResponsive = this._onPtyHostResponsive.event;
|
||||||
private readonly _onPtyHostRestart = this._register(new Emitter<void>());
|
private readonly _onPtyHostRestart = this._register(new Emitter<void>());
|
||||||
readonly onPtyHostRestart = this._onPtyHostRestart.event;
|
readonly onPtyHostRestart = this._onPtyHostRestart.event;
|
||||||
|
private readonly _onPtyHostRequestResolveVariables = this._register(new Emitter<IRequestResolveVariablesEvent>());
|
||||||
|
readonly onPtyHostRequestResolveVariables = this._onPtyHostRequestResolveVariables.event;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@IRemoteAgentService private readonly _remoteAgentService: IRemoteAgentService,
|
@IRemoteAgentService private readonly _remoteAgentService: IRemoteAgentService,
|
||||||
|
@ -41,7 +48,10 @@ export class RemoteTerminalService extends Disposable implements IRemoteTerminal
|
||||||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||||
@ICommandService private readonly _commandService: ICommandService,
|
@ICommandService private readonly _commandService: ICommandService,
|
||||||
@INotificationService notificationService: INotificationService,
|
@INotificationService notificationService: INotificationService,
|
||||||
@IRemoteAuthorityResolverService private readonly _remoteAuthorityResolverService: IRemoteAuthorityResolverService
|
@IRemoteAuthorityResolverService private readonly _remoteAuthorityResolverService: IRemoteAuthorityResolverService,
|
||||||
|
@IWorkspaceContextService workspaceContextService: IWorkspaceContextService,
|
||||||
|
@IConfigurationResolverService configurationResolverService: IConfigurationResolverService,
|
||||||
|
@IHistoryService historyService: IHistoryService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -122,6 +132,13 @@ export class RemoteTerminalService extends Disposable implements IRemoteTerminal
|
||||||
this._onPtyHostResponsive.fire();
|
this._onPtyHostResponsive.fire();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
this._register(channel.onPtyHostRequestResolveVariables(async e => {
|
||||||
|
const activeWorkspaceRootUri = historyService.getLastActiveWorkspaceRoot(Schemas.file);
|
||||||
|
const lastActiveWorkspaceRoot = activeWorkspaceRootUri ? withNullAsUndefined(workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri)) : undefined;
|
||||||
|
const resolveCalls: Promise<string>[] = e.text.map(t => configurationResolverService.resolveAsync(lastActiveWorkspaceRoot, t));
|
||||||
|
const result = await Promise.all(resolveCalls);
|
||||||
|
channel.acceptPtyHostResolvedVariables(e.id, result);
|
||||||
|
}));
|
||||||
} else {
|
} else {
|
||||||
this._remoteTerminalChannel = null;
|
this._remoteTerminalChannel = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
|
||||||
import { Schemas } from 'vs/base/common/network';
|
import { Schemas } from 'vs/base/common/network';
|
||||||
import { ILabelService } from 'vs/platform/label/common/label';
|
import { ILabelService } from 'vs/platform/label/common/label';
|
||||||
import { IEnvironmentVariableService, ISerializableEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
|
import { IEnvironmentVariableService, ISerializableEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
|
||||||
import { IProcessDataEvent, IShellLaunchConfig, IShellLaunchConfigDto, ITerminalDimensionsOverride, ITerminalEnvironment, ITerminalLaunchError, ITerminalProfile, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalShellType } from 'vs/platform/terminal/common/terminal';
|
import { IProcessDataEvent, IRequestResolveVariablesEvent, IShellLaunchConfig, IShellLaunchConfigDto, ITerminalDimensionsOverride, ITerminalEnvironment, ITerminalLaunchError, ITerminalProfile, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalShellType } from 'vs/platform/terminal/common/terminal';
|
||||||
import { IGetTerminalLayoutInfoArgs, IProcessDetails, IPtyHostProcessReplayEvent, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess';
|
import { IGetTerminalLayoutInfoArgs, IProcessDetails, IPtyHostProcessReplayEvent, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess';
|
||||||
import { IProcessEnvironment, OperatingSystem } from 'vs/base/common/platform';
|
import { IProcessEnvironment, OperatingSystem } from 'vs/base/common/platform';
|
||||||
|
|
||||||
|
@ -84,6 +84,9 @@ export class RemoteTerminalChannelClient {
|
||||||
get onPtyHostResponsive(): Event<void> {
|
get onPtyHostResponsive(): Event<void> {
|
||||||
return this._channel.listen<void>('$onPtyHostResponsiveEvent');
|
return this._channel.listen<void>('$onPtyHostResponsiveEvent');
|
||||||
}
|
}
|
||||||
|
get onPtyHostRequestResolveVariables(): Event<IRequestResolveVariablesEvent> {
|
||||||
|
return this._channel.listen<IRequestResolveVariablesEvent>('$onPtyHostRequestResolveVariablesEvent');
|
||||||
|
}
|
||||||
get onProcessData(): Event<{ id: number, event: IProcessDataEvent | string }> {
|
get onProcessData(): Event<{ id: number, event: IProcessDataEvent | string }> {
|
||||||
return this._channel.listen<{ id: number, event: IProcessDataEvent | string }>('$onProcessDataEvent');
|
return this._channel.listen<{ id: number, event: IProcessDataEvent | string }>('$onProcessDataEvent');
|
||||||
}
|
}
|
||||||
|
@ -238,6 +241,9 @@ export class RemoteTerminalChannelClient {
|
||||||
getProfiles(includeDetectedProfiles?: boolean): Promise<ITerminalProfile[]> {
|
getProfiles(includeDetectedProfiles?: boolean): Promise<ITerminalProfile[]> {
|
||||||
return this._channel.call('$getProfiles', [includeDetectedProfiles]);
|
return this._channel.call('$getProfiles', [includeDetectedProfiles]);
|
||||||
}
|
}
|
||||||
|
acceptPtyHostResolvedVariables(id: number, resolved: string[]) {
|
||||||
|
return this._channel.call('$acceptPtyHostResolvedVariables', [id, resolved]);
|
||||||
|
}
|
||||||
|
|
||||||
getEnvironment(): Promise<IProcessEnvironment> {
|
getEnvironment(): Promise<IProcessEnvironment> {
|
||||||
return this._channel.call('$getEnvironment');
|
return this._channel.call('$getEnvironment');
|
||||||
|
|
|
@ -104,12 +104,10 @@ export class LocalTerminalService extends Disposable implements ILocalTerminalSe
|
||||||
}
|
}
|
||||||
if (this._localPtyService.onPtyHostRequestResolveVariables) {
|
if (this._localPtyService.onPtyHostRequestResolveVariables) {
|
||||||
this._register(this._localPtyService.onPtyHostRequestResolveVariables(async e => {
|
this._register(this._localPtyService.onPtyHostRequestResolveVariables(async e => {
|
||||||
this._logService.info('localTerminalService request', e.id, e.text);
|
|
||||||
const activeWorkspaceRootUri = historyService.getLastActiveWorkspaceRoot(Schemas.file);
|
const activeWorkspaceRootUri = historyService.getLastActiveWorkspaceRoot(Schemas.file);
|
||||||
const lastActiveWorkspaceRoot = activeWorkspaceRootUri ? withNullAsUndefined(this._workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri)) : undefined;
|
const lastActiveWorkspaceRoot = activeWorkspaceRootUri ? withNullAsUndefined(this._workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri)) : undefined;
|
||||||
const resolveCalls: Promise<string>[] = e.text.map(t => configurationResolverService.resolveAsync(lastActiveWorkspaceRoot, t));
|
const resolveCalls: Promise<string>[] = e.text.map(t => configurationResolverService.resolveAsync(lastActiveWorkspaceRoot, t));
|
||||||
const result = await Promise.all(resolveCalls);
|
const result = await Promise.all(resolveCalls);
|
||||||
this._logService.info('resolved', result);
|
|
||||||
this._localPtyService.acceptPtyHostResolvedVariables?.(e.id, result);
|
this._localPtyService.acceptPtyHostResolvedVariables?.(e.id, result);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue