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

Enable file links when task terminals complete #9695

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: 4 additions & 0 deletions packages/task/src/browser/task-terminal-widget-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { PanelKind, TaskConfiguration, TaskWatcher, TaskExitedEvent, TaskServer,
import { ProcessTaskInfo } from '../common/process/task-protocol';
import { TaskDefinitionRegistry } from './task-definition-registry';
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
import URI from '@theia/core/lib/common/uri';

export interface TaskTerminalWidget extends TerminalWidget {
readonly kind: 'task';
Expand Down Expand Up @@ -195,10 +196,13 @@ export class TaskTerminalWidgetManager {
}

// we are unable to find a terminal widget to run the task, or `taskPresentation === 'new'`
const lastCwd = new URI(taskConfig?.options.cwd);
if (!reusableTerminalWidget) {
const widget = await this.newTaskTerminal(factoryOptions);
widget.lastCwd = lastCwd;
return { isNew: true, widget };
}
reusableTerminalWidget.lastCwd = lastCwd;
return { isNew: false, widget: reusableTerminalWidget };
}

Expand Down
3 changes: 3 additions & 0 deletions packages/terminal/src/browser/base/terminal-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export abstract class TerminalWidget extends BaseWidget {

abstract readonly dimensions: TerminalDimensions;

/** The last CWD assigned to the terminal, useful when attempting getCwdURI on a task terminal fails */
lastCwd: URI | undefined;

/**
* Start terminal and return terminal id.
* @param id - terminal id.
Expand Down
6 changes: 5 additions & 1 deletion packages/terminal/src/browser/terminal-widget-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
protected hoverMessage: HTMLDivElement;
protected lastTouchEnd: TouchEvent | undefined;
protected isAttachedCloseListener: boolean = false;
lastCwd: URI;

@inject(WorkspaceService) protected readonly workspaceService: WorkspaceService;
@inject(WebSocketConnectionProvider) protected readonly webSocketConnectionProvider: WebSocketConnectionProvider;
Expand Down Expand Up @@ -298,7 +299,10 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
}
if (this.terminalService.getById(this.id)) {
return this.shellTerminalServer.getCwdURI(this.terminalId)
.then(cwdUrl => new URI(cwdUrl));
.then(cwdUrl => {
this.lastCwd = new URI(cwdUrl);
return this.lastCwd;
}).catch(() => this.lastCwd);
}
return Promise.resolve(new URI());
}
Expand Down