Skip to content

Commit 83bd43b

Browse files
authored
Merge pull request #132870 from microsoft/tyriar/r160_pty
Fix launching Pseudoterminal-based and local terminals in remote workspaces before the connection is established
2 parents 5e2f963 + 3361f8d commit 83bd43b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/vs/workbench/api/browser/mainThreadTerminalService.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,15 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
140140
isExtensionOwnedTerminal: launchConfig.isExtensionOwnedTerminal,
141141
useShellEnvironment: launchConfig.useShellEnvironment,
142142
};
143-
this._extHostTerminals.set(extHostTerminalId, new Promise(async r => {
143+
const terminal = new Promise<ITerminalInstance>(async r => {
144144
const terminal = await this._terminalService.createTerminal({
145145
config: shellLaunchConfig,
146146
location: await this._deserializeParentTerminal(launchConfig.location)
147147
});
148148
r(terminal);
149-
}));
149+
});
150+
this._extHostTerminals.set(extHostTerminalId, terminal);
151+
await terminal;
150152
}
151153

152154
private async _deserializeParentTerminal(location?: TerminalLocation | TerminalEditorLocationOptions | { parentTerminal: ExtHostTerminalIdentifier } | { splitActiveTerminal: boolean, location?: TerminalLocation }): Promise<TerminalLocation | TerminalEditorLocationOptions | { parentTerminal: ITerminalInstance } | { splitActiveTerminal: boolean } | undefined> {

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,9 +1148,17 @@ export class TerminalService implements ITerminalService {
11481148

11491149

11501150
async createTerminal(options?: ICreateTerminalOptions): Promise<ITerminalInstance> {
1151+
// Await the initialization of available profiles as long as this is not a pty terminal or a
1152+
// local terminal in a remote workspace as profile won't be used in those cases and these
1153+
// terminals need to be launched before remote connections are established.
11511154
if (!this._availableProfiles) {
1152-
await this._refreshAvailableProfilesNow();
1155+
const isPtyTerminal = options?.config && 'customPtyImplementation' in options.config;
1156+
const isLocalInRemoteTerminal = this._remoteAgentService.getConnection() && URI.isUri(options?.cwd) && options?.cwd.scheme === Schemas.vscodeFileResource;
1157+
if (!isPtyTerminal && !isLocalInRemoteTerminal) {
1158+
await this._refreshAvailableProfilesNow();
1159+
}
11531160
}
1161+
11541162
const config = options?.config || this._availableProfiles?.find(p => p.profileName === this._defaultProfileName);
11551163
const shellLaunchConfig = config && 'extensionIdentifier' in config ? {} : this._convertProfileToShellLaunchConfig(config || {});
11561164

0 commit comments

Comments
 (0)