Skip to content

Commit

Permalink
add refresh code
Browse files Browse the repository at this point in the history
  • Loading branch information
spgennard committed Jan 2, 2025
1 parent 73920f4 commit a0c8f74
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/vsdotmarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,20 @@ export async function view_dot_callgraph(context: vscode.ExtensionContext, setti
undefined,
context.subscriptions
);

setHtmlContent(webviewPanel.webview, context, linesArray);

vscode.workspace.onDidChangeTextDocument(changeEvent => {
if (vscode.window.activeTextEditor?.document) {
if (changeEvent.document.uri != vscode.window.activeTextEditor.document.uri) return;
let current = VSCOBOLSourceScanner.getCachedObject(vscode.window.activeTextEditor.document, settings);
if (current === undefined) {
return;
}
const updatedLinesArray: string[] = getCurrentProgramCallGraph(settings, current, false);
setHtmlContent(webviewPanel.webview, context, updatedLinesArray);
}
});
}

function saveAsPng(messageText: string) {
Expand All @@ -76,7 +89,8 @@ function saveAsPng(messageText: string) {
}

function setHtmlContent(webview: vscode.Webview, extensionContext: vscode.ExtensionContext, linesArray: string[]) {
let htmlContent = `<html>
let htmlContent = `<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Expand All @@ -86,7 +100,7 @@ function setHtmlContent(webview: vscode.Webview, extensionContext: vscode.Extens
script-src 'nonce-nonce' 'unsafe-inline';
">
</head>
<body>
<body class="vscode-body">
<script type="text/javascript">
const _config = {
vscode: {
Expand Down Expand Up @@ -118,7 +132,7 @@ function setHtmlContent(webview: vscode.Webview, extensionContext: vscode.Extens
htmlContent = htmlContent.replace('nonce-nonce', `nonce-${nonce}`);
htmlContent = htmlContent.replace(/<script /g, `<script nonce="${nonce}" `);
htmlContent = htmlContent.replace(/<link /g, `<link nonce="${nonce}" `);

htmlContent = htmlContent.replace('cspSource', webview.cspSource);

webview.html = htmlContent;
Expand Down

0 comments on commit a0c8f74

Please sign in to comment.