VS Code Extension, how to programme a refresh of PlantUML preview

Viewed 2509

How can I force PlantUML to refresh its preview, using code?

Longer Explanation

I have 2 editors open Editor 1 contains a yml file. Editor 2 contains a plantuml .wsd file and a 3rd pane is showing the plantuml preview. (which is technically not an editor)

When I modify the yml file, it modifies a json model, and rewrites the .wsd file, and thus I get a new state diagram showing me the structure of my yml file in graph format.

The content of wsd is updating correctly when the yml changes. V1 created a new file each time, it saved fine I could see the content change, but the preview never updated.

Settings->PlantUML auto update is ticked.

In order to trigger the refresh I had to select the editor, and either modify or save.

So I re-wrote the code to select the editor 2 wsd contents, replace it in the existing file, and then save that file. Still the preview does not update.

I have also tried to fire the vscode command plantuml.preview, which is what the plantuml extension itself fires to display the preview, it fires and returns, but does not update the preview.

I have vscode.window.visibleTextEditors[ii], from which I can select the right editor, but I cannot find anything to set the focus. I've tried setting selections, and saving but still no refresh.

I am now trying to find the right vs code way to set the focus on the right editor and save it, then switch back to the left editor, mimicking pressing CMD-2, CMD-S, CMD-1, or manually selecting the editor and saving, which is the only way to update the preview.

I cannot find anything on how to set the editor focus, so perhaps I am going down the wrong path. Can anyone suggest how this could be done?

My 2 Editors and a Preview Panel

0 Answers
Related