Skip to content

Commit

Permalink
Fix error thrown after a task is completed
Browse files Browse the repository at this point in the history
Fixes #5328

Fix error thrown in the backend when after a task is completed.
Instead of calling the method `getCwdURI(terminalId)` first
check if the terminal with the given id truly exists.

Signed-off-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Jun 5, 2019
1 parent 92cfe9a commit e1b0bab
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/terminal/src/browser/terminal-widget-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { Deferred } from '@theia/core/lib/common/promise-util';
import { TerminalPreferences } from './terminal-preferences';
import { TerminalContribution } from './terminal-contribution';
import URI from '@theia/core/lib/common/uri';
import { TerminalService } from './base/terminal-service';

export const TERMINAL_WIDGET_FACTORY_ID = 'terminal';

Expand Down Expand Up @@ -73,6 +74,7 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
@inject('terminal-dom-id') public readonly id: string;
@inject(TerminalPreferences) protected readonly preferences: TerminalPreferences;
@inject(ContributionProvider) @named(TerminalContribution) protected readonly terminalContributionProvider: ContributionProvider<TerminalContribution>;
@inject(TerminalService) protected readonly terminalService: TerminalService;

protected readonly onDidOpenEmitter = new Emitter<void>();
readonly onDidOpen: Event<void> = this.onDidOpenEmitter.event;
Expand Down Expand Up @@ -205,7 +207,11 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
if (!IBaseTerminalServer.validateId(this.terminalId)) {
throw new Error('terminal is not started');
}
return this.shellTerminalServer.getCwdURI(this.terminalId).then(cwdUrl => new URI(cwdUrl));
if (this.terminalService.getById(this.terminalId.toString())) {
return this.shellTerminalServer.getCwdURI(this.terminalId)
.then(cwdUrl => new URI(cwdUrl));
}
return Promise.resolve(new URI());
}

get processId(): Promise<number> {
Expand Down

0 comments on commit e1b0bab

Please sign in to comment.