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
142 stars 22 forks source link

the highlight() function is not working as expect for nodes including ":" symbol #172

Open liijunwei opened 1 week ago

liijunwei commented 1 week ago

hi @tintinweb , really appreciated that you shared this plugin on vscode, it's been quite helpful for my daily work especially the "bidirectional highlight" feature, makes upstreams and downstreams quite clear instantly

while using I found some unexpected behavior though, and I'd like to report and propose an quick fix to optimize the user experience 🙏

Minimal, Reproducible Example

digraph G {
  rankdir = LR;
  node [shape = note;];

  // bidirectional highlight works well
  z -> a;
  y -> a;
  a -> b -> d;
  b -> c -> e;
  a -> e;

  // bidirectional highlight works unexpected
  // e.g. click "c:d:e", "e:f:g" and "d:e:f" are not highlighted
  "a:b:c" -> "b:c:d";
  "b:c:d" -> "c:d:e";
  "c:d:e" -> "d:e:f";
  "c:d:e" -> "e:f:g";
  "g:h:i" -> "h:i:j";
  "h:i:j" -> "d:e:f";
  "h:i:j" -> "e:f:g";
  "c:d:e" -> "foo";
}

image

rough cause

it's using connection[0].split(":")[0]; and connection[1].split(":")[0]; in jquery.graphviz.svg.js

which implicitly depends on the format of node identifier

quick fix

removing .split(":")[0] from GraphvizSvg.prototype.linkedTo and GraphvizSvg.prototype.linkedFrom

later I checked out jquery.graphviz.svg.js source code and found the copy in source code is a bit outdated, if I copy the code here, everything works fine

liijunwei commented 1 week ago

one more question to the author and contributors: I found I'm not able to make console.log or breakpoint to work in vscode-interactive-graphviz/content/highlighting.js (within Extension Development Host), it makes reasoning and debugging very very hard for me, could you share how did you debug while developing the extension?