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

Fix render of empty webview on new model check #298

Merged
merged 1 commit into from
Jul 23, 2023
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
3 changes: 2 additions & 1 deletion src/commands/checkModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ModelCheckResult, ModelCheckResultSource, SpecFiles } from '../model/ch
import { ToolOutputChannel } from '../outputChannels';
import { saveStreamToFile } from '../outputSaver';
import {
revealEmptyCheckResultView,
revealLastCheckResultView,
updateCheckResultView
} from '../panels/checkResultView';
Expand Down Expand Up @@ -192,7 +193,7 @@ export async function doCheckModel(
});
if (showCheckResultView) {
attachFileSaver(specFiles.tlaFilePath, checkProcess);
revealLastCheckResultView(extContext);
revealEmptyCheckResultView(extContext);
}
const resultHolder = new CheckResultHolder();
const checkResultCallback = (checkResult: ModelCheckResult) => {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/visualizeOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from 'fs';
import { PassThrough } from 'stream';
import * as vscode from 'vscode';
import { ModelCheckResultSource } from '../model/check';
import { revealLastCheckResultView, updateCheckResultView } from '../panels/checkResultView';
import { revealEmptyCheckResultView, updateCheckResultView } from '../panels/checkResultView';
import { TlcModelCheckerStdoutParser } from '../parsers/tlc';

export const CMD_VISUALIZE_TLC_OUTPUT = 'tlaplus.out.visualize';
Expand Down Expand Up @@ -34,7 +34,7 @@ export function visualizeTlcOutput(extContext: vscode.ExtensionContext): void {
function showOutput(buffer: Buffer, extContext: vscode.ExtensionContext) {
const stream = new PassThrough();
stream.end(buffer);
revealLastCheckResultView(extContext);
revealEmptyCheckResultView(extContext);
const parser = new TlcModelCheckerStdoutParser(
ModelCheckResultSource.OutFile, stream, undefined, false, updateCheckResultView);
parser.readAll();
Expand Down
23 changes: 13 additions & 10 deletions src/panels/checkResultView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class CheckResultViewPanel {
vscode.ViewColumn.Beside,
{
enableScripts: true,
retainContextWhenHidden: true,
localResourceRoots: [vscode.Uri.joinPath(extensionUri, 'out')]
}
);
Expand Down Expand Up @@ -64,23 +65,25 @@ class CheckResultViewPanel {
}

public static renderEmpty(extensionUri: vscode.Uri) {
if (CheckResultViewPanel.currentPanel) {
CheckResultViewPanel.currentPanel.dispose();
if (!CheckResultViewPanel.currentPanel) {
CheckResultViewPanel.currentPanel = new CheckResultViewPanel(extensionUri);
}

CheckResultViewPanel.currentPanel = new CheckResultViewPanel(extensionUri);
this.updateCheckResult(ModelCheckResult.createEmpty(ModelCheckResultSource.Process));
CheckResultViewPanel.currentPanel.panel.reveal();
}

public static renderLastResult(extensionUri: vscode.Uri) {
if (CheckResultViewPanel.currentPanel) {
CheckResultViewPanel.currentPanel.panel.reveal();
return;
if (!CheckResultViewPanel.currentPanel) {
CheckResultViewPanel.currentPanel = new CheckResultViewPanel(extensionUri);
}

CheckResultViewPanel.currentPanel = new CheckResultViewPanel(extensionUri);
if (CheckResultViewPanel.lastCheckResult) {
CheckResultViewPanel.currentPanel.updateView(CheckResultViewPanel.lastCheckResult);
}
const lastModelResult = CheckResultViewPanel.lastCheckResult
? CheckResultViewPanel.lastCheckResult
: ModelCheckResult.createEmpty(ModelCheckResultSource.Process);

this.updateCheckResult(lastModelResult);
CheckResultViewPanel.currentPanel.panel.reveal();
}

private updateView(checkResult: ModelCheckResult) {
Expand Down
Loading