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 { URI } from 'vs/base/common/uri';
|
||||
import { joinPath } from 'vs/base/common/resources';
|
||||
import { registerTerminalPlatformConfiguration } from 'vs/platform/terminal/common/terminalPlatformConfiguration';
|
||||
|
||||
class SharedProcessMain extends Disposable {
|
||||
|
||||
|
@ -116,7 +115,6 @@ class SharedProcessMain extends Disposable {
|
|||
|
||||
// Config
|
||||
registerUserDataSyncConfiguration();
|
||||
registerTerminalPlatformConfiguration();
|
||||
|
||||
instantiationService.invokeFunction(accessor => {
|
||||
const logService = accessor.get(ILogService);
|
||||
|
|
|
@ -16,6 +16,7 @@ import { IGetTerminalLayoutInfoArgs, IProcessDetails, IPtyHostProcessReplayEvent
|
|||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { detectAvailableProfiles } from 'vs/platform/terminal/node/terminalProfiles';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { registerTerminalPlatformConfiguration } from 'vs/platform/terminal/common/terminalPlatformConfiguration';
|
||||
|
||||
enum Constants {
|
||||
MaxRestarts = 5
|
||||
|
@ -77,9 +78,6 @@ export class PtyHostService extends Disposable implements IPtyService {
|
|||
private readonly _onProcessOrphanQuestion = this._register(new Emitter<{ id: number }>());
|
||||
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(
|
||||
@IConfigurationService private readonly _configurationService: IConfigurationService,
|
||||
@ILogService private readonly _logService: ILogService,
|
||||
|
@ -87,6 +85,10 @@ export class PtyHostService extends Disposable implements IPtyService {
|
|||
) {
|
||||
super();
|
||||
|
||||
// Platform configuration is required on the process running the pty host (shared process or
|
||||
// remote server).
|
||||
registerTerminalPlatformConfiguration();
|
||||
|
||||
this._register(toDisposable(() => this._disposePtyHost()));
|
||||
|
||||
[this._client, this._proxy] = this._startPtyHost();
|
||||
|
@ -218,16 +220,8 @@ export class PtyHostService extends Disposable implements IPtyService {
|
|||
return this._proxy.getDefaultSystemShell(osOverride);
|
||||
}
|
||||
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
|
||||
const r = await detectAvailableProfiles(!includeDetectedProfiles, this._buildSafeConfigProvider(), undefined, this._logService, this._resolveVariables.bind(this));
|
||||
this._logService.info('profiles', r);
|
||||
return r;
|
||||
// return this._proxy.getProfiles?.(includeDetectedProfiles) || [];
|
||||
return detectAvailableProfiles(!includeDetectedProfiles, this._buildSafeConfigProvider(), undefined, this._logService, this._resolveVariables.bind(this));
|
||||
}
|
||||
getEnvironment(): Promise<IProcessEnvironment> {
|
||||
return this._proxy.getEnvironment();
|
||||
|
|
|
@ -42,7 +42,6 @@ export function detectAvailableProfiles(
|
|||
workspaceFolder
|
||||
);
|
||||
}
|
||||
console.log('config provider result', safeConfigProvider(`terminal.integrated.profiles.${isMacintosh ? 'osx' : 'linux'}`));
|
||||
return detectAvailableUnixProfiles(
|
||||
fsProvider,
|
||||
logService,
|
||||
|
@ -154,12 +153,7 @@ async function transformToTerminalProfiles(entries: IterableIterator<[string, IT
|
|||
icon = profile.icon;
|
||||
}
|
||||
|
||||
// const paths = 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);
|
||||
if (validatedProfile) {
|
||||
validatedProfile.isAutoDetected = profile.isAutoDetected;
|
||||
|
@ -290,8 +284,6 @@ async function detectAvailableUnixProfiles(
|
|||
|
||||
applyConfigProfilesToMap(configProfiles, detectedProfiles);
|
||||
|
||||
console.log('detected', detectedProfiles);
|
||||
|
||||
return await transformToTerminalProfiles(detectedProfiles.entries(), defaultProfileName, fsProvider, logService, variableResolver, workspaceFolder);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
import { Emitter } from 'vs/base/common/event';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { revive } from 'vs/base/common/marshalling';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IProcessEnvironment, OperatingSystem } from 'vs/base/common/platform';
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { localize } from 'vs/nls';
|
||||
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 { INotificationHandle, INotificationService, IPromptChoice, Severity } from 'vs/platform/notification/common/notification';
|
||||
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 { IRemoteTerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
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 { 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';
|
||||
|
||||
export class RemoteTerminalService extends Disposable implements IRemoteTerminalService {
|
||||
|
@ -34,6 +39,8 @@ export class RemoteTerminalService extends Disposable implements IRemoteTerminal
|
|||
readonly onPtyHostResponsive = this._onPtyHostResponsive.event;
|
||||
private readonly _onPtyHostRestart = this._register(new Emitter<void>());
|
||||
readonly onPtyHostRestart = this._onPtyHostRestart.event;
|
||||
private readonly _onPtyHostRequestResolveVariables = this._register(new Emitter<IRequestResolveVariablesEvent>());
|
||||
readonly onPtyHostRequestResolveVariables = this._onPtyHostRequestResolveVariables.event;
|
||||
|
||||
constructor(
|
||||
@IRemoteAgentService private readonly _remoteAgentService: IRemoteAgentService,
|
||||
|
@ -41,7 +48,10 @@ export class RemoteTerminalService extends Disposable implements IRemoteTerminal
|
|||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||
@ICommandService private readonly _commandService: ICommandService,
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IRemoteAuthorityResolverService private readonly _remoteAuthorityResolverService: IRemoteAuthorityResolverService
|
||||
@IRemoteAuthorityResolverService private readonly _remoteAuthorityResolverService: IRemoteAuthorityResolverService,
|
||||
@IWorkspaceContextService workspaceContextService: IWorkspaceContextService,
|
||||
@IConfigurationResolverService configurationResolverService: IConfigurationResolverService,
|
||||
@IHistoryService historyService: IHistoryService
|
||||
) {
|
||||
super();
|
||||
|
||||
|
@ -122,6 +132,13 @@ export class RemoteTerminalService extends Disposable implements IRemoteTerminal
|
|||
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 {
|
||||
this._remoteTerminalChannel = null;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
|
|||
import { Schemas } from 'vs/base/common/network';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
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 { IProcessEnvironment, OperatingSystem } from 'vs/base/common/platform';
|
||||
|
||||
|
@ -84,6 +84,9 @@ export class RemoteTerminalChannelClient {
|
|||
get onPtyHostResponsive(): Event<void> {
|
||||
return this._channel.listen<void>('$onPtyHostResponsiveEvent');
|
||||
}
|
||||
get onPtyHostRequestResolveVariables(): Event<IRequestResolveVariablesEvent> {
|
||||
return this._channel.listen<IRequestResolveVariablesEvent>('$onPtyHostRequestResolveVariablesEvent');
|
||||
}
|
||||
get onProcessData(): Event<{ id: number, event: IProcessDataEvent | string }> {
|
||||
return this._channel.listen<{ id: number, event: IProcessDataEvent | string }>('$onProcessDataEvent');
|
||||
}
|
||||
|
@ -238,6 +241,9 @@ export class RemoteTerminalChannelClient {
|
|||
getProfiles(includeDetectedProfiles?: boolean): Promise<ITerminalProfile[]> {
|
||||
return this._channel.call('$getProfiles', [includeDetectedProfiles]);
|
||||
}
|
||||
acceptPtyHostResolvedVariables(id: number, resolved: string[]) {
|
||||
return this._channel.call('$acceptPtyHostResolvedVariables', [id, resolved]);
|
||||
}
|
||||
|
||||
getEnvironment(): Promise<IProcessEnvironment> {
|
||||
return this._channel.call('$getEnvironment');
|
||||
|
|
|
@ -104,12 +104,10 @@ export class LocalTerminalService extends Disposable implements ILocalTerminalSe
|
|||
}
|
||||
if (this._localPtyService.onPtyHostRequestResolveVariables) {
|
||||
this._register(this._localPtyService.onPtyHostRequestResolveVariables(async e => {
|
||||
this._logService.info('localTerminalService request', e.id, e.text);
|
||||
const activeWorkspaceRootUri = historyService.getLastActiveWorkspaceRoot(Schemas.file);
|
||||
const lastActiveWorkspaceRoot = activeWorkspaceRootUri ? withNullAsUndefined(this._workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri)) : undefined;
|
||||
const resolveCalls: Promise<string>[] = e.text.map(t => configurationResolverService.resolveAsync(lastActiveWorkspaceRoot, t));
|
||||
const result = await Promise.all(resolveCalls);
|
||||
this._logService.info('resolved', result);
|
||||
this._localPtyService.acceptPtyHostResolvedVariables?.(e.id, result);
|
||||
}));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue