Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly pass selected workspace root to terminal profile #12199

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/terminal/src/browser/shell-terminal-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
// *****************************************************************************

import { IShellTerminalServerOptions } from '../common/shell-terminal-protocol';
import { URI } from '@theia/core';
import { TerminalService } from './base/terminal-service';
import { TerminalWidget, TerminalWidgetOptions } from './base/terminal-widget';
import { TerminalProfile } from './terminal-profile-service';
Expand All @@ -34,7 +34,7 @@ export class ShellTerminalProfile implements TerminalProfile {
* @param options the options to override
* @returns a modified copy of this profile
*/
modify(options: IShellTerminalServerOptions): TerminalProfile {
modify(options: { cwd?: string | URI }): TerminalProfile {
return new ShellTerminalProfile(this.terminalService, { ...this.options, ...options });
}
}
12 changes: 9 additions & 3 deletions packages/terminal/src/browser/terminal-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -932,14 +932,17 @@ export class TerminalFrontendContribution implements FrontendApplicationContribu
}

protected async openTerminal(options?: ApplicationShell.WidgetOptions): Promise<void> {
const cwd = await this.selectTerminalCwd();
let profile = this.profileService.defaultProfile;

if (!profile) {
throw new Error('There are not profiles registered');
}
if (profile instanceof ShellTerminalProfile) {
profile = profile.modify({ rootURI: cwd });
const cwd = await this.selectTerminalCwd();
if (!cwd) {
return;
}
profile = profile.modify({ cwd });
}

const termWidget = await profile?.start();
Expand All @@ -955,7 +958,10 @@ export class TerminalFrontendContribution implements FrontendApplicationContribu
let profile = result[1];
if (profile instanceof ShellTerminalProfile) {
const cwd = await this.selectTerminalCwd();
profile = profile.modify({ rootURI: cwd });
if (!cwd) {
return;
}
profile = profile.modify({ cwd });
}
const termWidget = await profile.start();
this.open(termWidget, { widgetOptions: options });
Expand Down