in client/src/extension.ts [134:164]
function reloadSidePreview(file:string, languageClient:LanguageClient) {
let uri = Uri.parse(file);
let stringifiedUri = uri.toString();
let dotFile = uri.fsPath + ".dot";
if (!fs.existsSync(dotFile)) {
window.showErrorMessage("Error previewing graph. Please run `pip3 install cfn-lint pydot --upgrade`");
return;
}
let content = fs.readFileSync(dotFile, 'utf8');
if (!previews[stringifiedUri]) {
previews[stringifiedUri] = VsCodeWindow.createWebviewPanel(
'cfnLintPreview', // Identifies the type of the webview. Used internally
'Template: ' + dotFile.slice(0,-4), // Title of the panel displayed to the user
ViewColumn.Two, // Editor column to show the new webview panel in.
{
enableScripts: true,
}
);
previews[stringifiedUri].onDidDispose(() => {
// if the user closed the preview
delete previews[stringifiedUri];
fs.unlinkSync(dotFile);
languageClient.sendNotification('cfn/previewClosed', stringifiedUri);
});
}
const panel = previews[stringifiedUri];
panel.webview.html = getPreviewContent(content);
}