From 96a1b612076eaccf32f07ce2414f19c5c54dbedd Mon Sep 17 00:00:00 2001 From: Kenneth Marut Date: Fri, 2 Jul 2021 16:28:43 -0500 Subject: [PATCH] switch ordering of fallback --- packages/terminal/src/browser/terminal-widget-impl.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/terminal/src/browser/terminal-widget-impl.ts b/packages/terminal/src/browser/terminal-widget-impl.ts index d65cad33b3bef..de9e0fbdb04f6 100644 --- a/packages/terminal/src/browser/terminal-widget-impl.ts +++ b/packages/terminal/src/browser/terminal-widget-impl.ts @@ -17,7 +17,7 @@ import { Terminal, RendererType } from 'xterm'; import { FitAddon } from 'xterm-addon-fit'; import { inject, injectable, named, postConstruct } from '@theia/core/shared/inversify'; -import { ContributionProvider, Disposable, Event, Emitter, ILogger, DisposableCollection, MaybePromise } from '@theia/core'; +import { ContributionProvider, Disposable, Event, Emitter, ILogger, DisposableCollection } from '@theia/core'; import { Widget, Message, WebSocketConnectionProvider, StatefulWidget, isFirefox, MessageLoop, KeyCode } from '@theia/core/lib/browser'; import { isOSX } from '@theia/core/lib/common'; import { WorkspaceService } from '@theia/workspace/lib/browser'; @@ -293,13 +293,16 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget }; } - get cwd(): MaybePromise { + get cwd(): Promise { if (!IBaseTerminalServer.validateId(this.terminalId)) { return Promise.reject(new Error('terminal is not started')); } if (this.terminalService.getById(this.id)) { - return this.lastCwd || this.shellTerminalServer.getCwdURI(this.terminalId) - .then(cwdUrl => new URI(cwdUrl)); + return this.shellTerminalServer.getCwdURI(this.terminalId) + .then(cwdUrl => { + this.lastCwd = new URI(cwdUrl); + return this.lastCwd; + }).catch(() => this.lastCwd); } return Promise.resolve(new URI()); }