mjbvz / vscode-markdown-mermaid

Adds Mermaid diagram and flowchart support to VS Code's builtin markdown preview
https://marketplace.visualstudio.com/items?itemName=bierner.markdown-mermaid
MIT License
640 stars 115 forks source link

do not remove token content #121

Closed krajniks closed 2 years ago

krajniks commented 2 years ago

Hey.

I also had problems described in #103 and looked at the code execution.

I have noticed, that for some reason render function executes multiple times (probably when leaving window?). The second time around all content is empty, as it is removed/emptied in first pass. When you start editing file again, tokens are recreated and graph is shown.

not removing token.content seems to fix the behavior.

mjbvz commented 2 years ago

Does this cause any other unexpected behavior in your testing? What if you also remove the other lines the null out the token?

I think those came in through a PR originally and I'm not sure if they are still required

krajniks commented 2 years ago

Finally came around to this.

I did test it some more.

Tokens must be nulled otherwise they get render as html and mermaid can't deal with it. Tokens are always recalculated when file is edited, so current code works just fine in that case. Only when editor loses and regains focus, they are not recalculated and the cleard/nulled ones are used again, which results in no data for mermaid.

No other unexpected behaviour was observed.

mjbvz commented 2 years ago

Thanks for looking into this. Let's try it out in the next release!