Skip to content

Commit 9fb14cc

Browse files
committed
Allow local to get backend by checking from createTerminal in terminalService.ts
1 parent 44e725f commit 9fb14cc

File tree

2 files changed

+16
-25
lines changed

2 files changed

+16
-25
lines changed

src/vs/workbench/contrib/terminal/browser/terminalService.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -967,9 +967,9 @@ export class TerminalService extends Disposable implements ITerminalService {
967967
// Await the initialization of available profiles as long as this is not a pty terminal or a
968968
// local terminal in a remote workspace as profile won't be used in those cases and these
969969
// terminals need to be launched before remote connections are established.
970+
const isLocalInRemoteTerminal = this._remoteAgentService.getConnection() && URI.isUri(options?.cwd) && options?.cwd.scheme === Schemas.vscodeFileResource;
970971
if (this._terminalProfileService.availableProfiles.length === 0) {
971972
const isPtyTerminal = options?.config && 'customPtyImplementation' in options.config;
972-
const isLocalInRemoteTerminal = this._remoteAgentService.getConnection() && URI.isUri(options?.cwd) && options?.cwd.scheme === Schemas.vscodeFileResource;
973973
if (!isPtyTerminal && !isLocalInRemoteTerminal) {
974974
if (this._connectionState === TerminalConnectionState.Connecting) {
975975
mark(`code/terminal/willGetProfiles`);
@@ -981,7 +981,19 @@ export class TerminalService extends Disposable implements ITerminalService {
981981
}
982982
}
983983

984-
const config = options?.config || this._terminalProfileService.getDefaultProfile();
984+
let config = options?.config;
985+
if (!config && isLocalInRemoteTerminal) {
986+
const backend = await this._terminalInstanceService.getBackend(undefined);
987+
const executable = await backend?.getDefaultSystemShell();
988+
if (executable) {
989+
config = { executable };
990+
}
991+
}
992+
993+
if (!config) {
994+
config = this._terminalProfileService.getDefaultProfile();
995+
}
996+
985997
const shellLaunchConfig = config && 'extensionIdentifier' in config ? {} : this._terminalInstanceService.convertProfileToShellLaunchConfig(config || {});
986998

987999
// Get the contributed profile if it was provided

src/vs/workbench/contrib/terminal/electron-browser/terminalRemote.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ import { localize2 } from '../../../../nls.js';
99
import { INativeEnvironmentService } from '../../../../platform/environment/common/environment.js';
1010
import { IRemoteAuthorityResolverService } from '../../../../platform/remote/common/remoteAuthorityResolver.js';
1111
import { registerTerminalAction } from '../browser/terminalActions.js';
12-
import { TerminalCommandId, ITerminalProfileResolverService } from '../common/terminal.js';
13-
import { ITerminalLogService } from '../../../../platform/terminal/common/terminal.js';
12+
import { TerminalCommandId } from '../common/terminal.js';
1413
import { IHistoryService } from '../../../services/history/common/history.js';
15-
import { OS } from '../../../../base/common/platform.js';
1614

1715
export function registerRemoteContributions() {
1816
registerTerminalAction({
@@ -22,9 +20,6 @@ export function registerRemoteContributions() {
2220
const historyService = accessor.get(IHistoryService);
2321
const remoteAuthorityResolverService = accessor.get(IRemoteAuthorityResolverService);
2422
const nativeEnvironmentService = accessor.get(INativeEnvironmentService);
25-
const terminalProfileResolverService = accessor.get(ITerminalProfileResolverService);
26-
const terminalLogService = accessor.get(ITerminalLogService);
27-
2823
let cwd: URI | undefined;
2924
try {
3025
const activeWorkspaceRootUri = historyService.getLastActiveWorkspaceRoot(Schemas.vscodeRemote);
@@ -38,23 +33,7 @@ export function registerRemoteContributions() {
3833
if (!cwd) {
3934
cwd = nativeEnvironmentService.userHome;
4035
}
41-
42-
// Make sure to explicitly get the local default profile
43-
const localProfile = await terminalProfileResolverService.getDefaultProfile({
44-
remoteAuthority: undefined,
45-
os: OS
46-
});
47-
terminalLogService.trace('terminalRemote#newLocal resolved profile', {
48-
os: OS,
49-
profileName: localProfile?.profileName,
50-
isAutoDetected: localProfile?.isAutoDetected ?? false
51-
});
52-
53-
// Create terminal with explicit local profile configuration
54-
const instance = await c.service.createTerminal({
55-
cwd,
56-
config: localProfile
57-
});
36+
const instance = await c.service.createTerminal({ cwd });
5837
if (!instance) {
5938
return Promise.resolve(undefined);
6039
}

0 commit comments

Comments
 (0)