cssho / vscode-svgviewer

SVG Viewer for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=cssho.vscode-svgviewer
MIT License
67 stars 20 forks source link

Added context menu command to open SVG file with file-watcher enabled #30

Closed harmishhk closed 7 years ago

harmishhk commented 7 years ago

This commit adds an explorer context menu for viewing an SVG file without opening it into an editor window. Plus, it watches this file for any changes. Thus if the file is changes from external programs the view is automatically updated.

My use case: I sometime use diagrams library which can generate SVG diagrams using the SVG backend. Which can run in a loop mode, so if I change the Haskell code for the diagram and save it, it will automatically re-built the file and generate SVG file. I would like the viewer to automatically update the view, so that I can change a Haskell file on left window and see the generated SVG on the right window without keep opening the additional editor window for the SVG file and clicking that window every time the file changes so that the view can catch the change. But there can be other use cases where other programs generating the SVG file rather than manually writing it.

Since the view window watches a file for changes, the viewer window is bound to the file and not the active editor in this case. Therefore I opted for context menu command. The context menu command is also helpful if someone just want to see the SVG output, they do not have to first open the file and then click on the icon to view the output.

This commit should not affect current functionalities of the extension. It just adds a new command. To check how it works you can install the extension from here: https://github.com/harmishhk/vscode-svgviewer/releases/tag/1.4.1.

cssho commented 7 years ago

Code LGTM.

cssho commented 7 years ago

Thanks for the PR @harmishhk . New version is up on the Visual Studio Marketplace.