diff --git a/src/extension.ts b/src/extension.ts index bfbedb3c6..81f275097 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -488,8 +488,10 @@ export class Extension implements RunHooks { return; const trace = result.attachments.find(a => a.name === 'trace')?.path || ''; + // if trace viewer is currently displaying the trace file about to be replaced, it needs to be refreshed + const prevTrace = (testItem as any)[traceUrlSymbol]; (testItem as any)[traceUrlSymbol] = trace; - if (enqueuedSingleTest) + if (enqueuedSingleTest || prevTrace === this._traceViewer.currentFile()) this._showTrace(testItem); if (result.status === test.expectedStatus) { diff --git a/src/traceViewer.ts b/src/traceViewer.ts index 43c9375e3..53272425e 100644 --- a/src/traceViewer.ts +++ b/src/traceViewer.ts @@ -26,6 +26,7 @@ export class TraceViewer implements vscodeTypes.Disposable { private _disposables: vscodeTypes.Disposable[] = []; private _traceViewerProcess: ChildProcess | undefined; private _settingsModel: SettingsModel; + private _currentFile?: string; constructor(vscode: vscodeTypes.VSCode, settingsModel: SettingsModel, envProvider: () => NodeJS.ProcessEnv) { this._vscode = vscode; @@ -38,6 +39,10 @@ export class TraceViewer implements vscodeTypes.Disposable { })); } + currentFile() { + return this._currentFile; + } + async willRunTests(config: TestConfig) { if (this._settingsModel.showTrace.get()) await this._startIfNeeded(config); @@ -52,6 +57,7 @@ export class TraceViewer implements vscodeTypes.Disposable { return; await this._startIfNeeded(config); this._traceViewerProcess?.stdin?.write(file + '\n'); + this._currentFile = file; } dispose() { @@ -85,6 +91,7 @@ export class TraceViewer implements vscodeTypes.Disposable { traceViewerProcess.stderr?.on('data', data => console.log(data.toString())); traceViewerProcess.on('exit', () => { this._traceViewerProcess = undefined; + this._currentFile = undefined; }); traceViewerProcess.on('error', error => { this._vscode.window.showErrorMessage(error.message);