tintinweb / vscode-interactive-graphviz

Interactive Graphviz Dot Preview for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=tintinweb.graphviz-interactive-preview
GNU General Public License v3.0
143 stars 22 forks source link

Extra line breaks are inserted on reformat #148

Open madhead opened 1 year ago

madhead commented 1 year ago

Observable behavior

I've installed the latest version of the extension (0.3.5) and configured these settings:

{
    "graphviz-interactive-preview.format.condenseAttributes": false,
    "graphviz-interactive-preview.view.themeColors": true
}

Now I'm trying to reformat a simple dot file:

digraph {
    A -> B [
        label = "A to B";
        URL = "http://www.google.com";
    ];
    B -> C [
        label = "B to C";
        URL = "http://www.google.com";
    ];
}

Every time I do that extra newlines are inserted between those two edges. Here is the video capture :point_down:

dot.webm

Expected behavior

I would expect at max one newline between the edges and this number should not increase on reformats. No extra newlines should be added.

madhead commented 1 year ago

I've run the extension in debug mode, and I think this is the piece of code that adds extra newlines:

https://github.com/tintinweb/vscode-interactive-graphviz/blob/1074d8c264b05c9460aeacf1027fc5c61e43ac29/src/language/DocumentFormatter.ts#L99-L103

What is this lastLine for?