Skip to content

Commit

Permalink
Correctly pass selected workspace root to terminal profile
Browse files Browse the repository at this point in the history
Fixes eclipse-theia#12197

Contributed on behalf of STMicroelectronics

Signed-off-by: Thomas Mäder <[email protected]>
  • Loading branch information
tsmaeder committed Feb 23, 2023
1 parent b9b0092 commit 5da2c2c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
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

0 comments on commit 5da2c2c

Please sign in to comment.