cyrusfirheir / twee3-language-tools

[ VSCode extension ] Syntax highlighting and programmatic language tools for Twee 3, and Twine 2 storyformats.
https://marketplace.visualstudio.com/items?itemName=cyrusfirheir.twee3-language-tools
MIT License
47 stars 16 forks source link

Support relative path variable substitution in SugarCube 2 macro definition descriptions #137

Closed JustNoon closed 1 year ago

JustNoon commented 1 year ago

Having a relative path for markdown images or links would help create nice documentation for local projects. Clickable links, previewable images, etc.

In VSCode, description pop-ups are in a restricted context that doesn't support relative paths.

exampleicon:
  name: exampleicon
  description: "![Example](icons/example.png)"

returns some sort of absolute path depending on environment (i.e. "vscode-file://vscode-app/c:/icons/example.png") All . / .. relative path indicators are stripped as well (probably for a good reason, maybe not though).

Adding full support for a relative path might introduce the same security blindspot VSCode is avoiding but a couple replacement strings would go a long way into adding more feature-rich descriptions while not having to deal with VSCode's protocol shenanigans.

description: "![Example](%workspaceFolder%/icons/example.png)"
description: "![Example](%definitionFolder%/example.png)"

An alternative solution to this would (and probably the correct one) would be to pass the macroDefinition's description as a MarkdownString so you can set baseUri as the current path.

JustNoon commented 1 year ago

Closing as merge effectively handles cases for this