Skip to content

Commit

Permalink
feat: open exported svg in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
ahtrotta committed Mar 2, 2023
1 parent 755b254 commit 65dcd26
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/editor/appmapEditorProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import { getStackLocations, StackLocation } from '../lib/getStackLocations';
import { ResolvedFinding } from '../services/resolvedFinding';
import getWebviewContent from '../webviews/getWebviewContent';
import ErrorCode from '../telemetry/definitions/errorCodes';
import { promisify } from 'util';
import { tmpName } from 'tmp';
import { writeFile } from 'fs/promises';

export type FindingInfo = ResolvedFinding & {
stackLocations?: StackLocation[];
Expand Down Expand Up @@ -223,16 +226,12 @@ export default class AppMapEditorProvider
{
try {
const { svgString } = message;
console.log('exportSVG received');
if (svgString) {
const comment =
'\n<!-- Save this SVG file with a .svg file extension ' +
'and then open it in a web browswer to view your appmap! -->\n\n';
const document = await vscode.workspace.openTextDocument({
language: 'svg',
content: comment + svgString,
});

vscode.window.showTextDocument(document);
const diagramFile = (await promisify(tmpName)()) + '.svg';
await writeFile(diagramFile, svgString);
const uri = vscode.Uri.file(diagramFile);
vscode.env.openExternal(uri);
Telemetry.sendEvent(EXPORT_SVG);
}
} catch (e) {
Expand Down

0 comments on commit 65dcd26

Please sign in to comment.