Closed protosam closed 1 year ago
Problem confirmed. Seems to be caused by the underlying libraries https://github.com/ts-graphviz/parser and https://github.com/ts-graphviz/ts-graphviz. I will try to investigate this further and report the problems there.
We used the parser from ts-graphviz/parser and the toDot method from ts-graphviz/ts-graphviz. Inbetween these two the comments get lost.
The following code uses parse and stringify from ts-graphviz/parser. This fixes the comments getting lost. However, the indentation seems to be off.
const d = AST.parse(document.getText());
const dot = AST.stringify(d);
Output of formatter has been adapted. Given the input from the start of the issue, the formatter now generates the following code by default (an option called graphviz-interactive-preview.format.condenseAttributes
has been introduced, which has an impact on how attributes are shown):
strict digraph {
/**
* This block comment is important or something.
*/
// I want to remember this later....
// layout = "dot";
node [fillcolor = "#ffffff";];
// general note related to nothing important
// cool info here about this connection
"hello" -> "graph";
}
Nice update! Found bug with the changes. Going to continue to conversation in the PR.
The problem is that if your graphviz file looks like this and you save it:
Gets transformed into this:
The assertions being made by the formatter are really wild.
Temporary solution for users is to just disable it.
CTRL+Shift+P
orCommand+Shift+P
)Preferences: Open Settings (JSON)