Skip to content

Commit

Permalink
Show cfgs in one tab instead of opening a new tab every time
Browse files Browse the repository at this point in the history
  • Loading branch information
karoliineh committed Jul 26, 2022
1 parent 769d33d commit 4c84439
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions vscode/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
import * as vscode from 'vscode';
import {ExtensionContext, ViewColumn, window, workspace} from 'vscode';
import {
ClientCapabilities,
Expand All @@ -14,6 +15,8 @@ import {
} from 'vscode-languageclient';
import {XMLHttpRequest} from 'xmlhttprequest-ts';

// Track currently webview panel
let panel: vscode.WebviewPanel | undefined = undefined;

export function activate(context: ExtensionContext) {
let script = 'java';
Expand Down Expand Up @@ -77,10 +80,27 @@ export class MagpieBridgeSupport implements DynamicFeature<undefined> {
}

createWebView(content: string) {
let panel = window.createWebviewPanel("Customized Web View", "GobPie", ViewColumn.Beside, {
retainContextWhenHidden: true,
enableScripts: true
});
const columnToShowIn = ViewColumn.Beside;

if (panel) {
// If we already have a panel, show it in the target column
panel.reveal(columnToShowIn);
} else {
// Otherwise, create a new panel
panel = window.createWebviewPanel("Customized Web View", "GobPie", columnToShowIn, {
retainContextWhenHidden: true,
enableScripts: true
});

// Reset when the current panel is closed
panel.onDidDispose(
() => {
panel = undefined;
},
null,
);
}

panel.webview.html = content;
panel.webview.onDidReceiveMessage(
message => {
Expand Down

0 comments on commit 4c84439

Please sign in to comment.