Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Variable Substitution #2

Open
yttriumz opened this issue Feb 9, 2023 · 4 comments
Open

Support for Variable Substitution #2

yttriumz opened this issue Feb 9, 2023 · 4 comments

Comments

@yttriumz
Copy link

yttriumz commented Feb 9, 2023

Is it possible to support variable substitution for the draw.directory setting like VSCode? Currently it does not support this feature. When I have "draw.directory": "${fileDirname}/attachments", this is the result:

image

@hall
Copy link
Owner

hall commented Feb 10, 2023

Hey @Alecton4! Thanks for submitting this issue. I agree this would be a nice feature but I'm not sure it's currently possible. There's an open feature request for it upstream though: microsoft/vscode#2809

@hall
Copy link
Owner

hall commented Feb 10, 2023

Found an unmaintained package that addresses this problem: vscode-variables (but doesn't work b/c the version of VSCode it depends on is too old)

So, I should say, this is possible to some extent. We could manually support a subset of these variables, for example. I'd agree that the one you've identified is probably one of the more useful ones.

Another option is to add a setting along the lines of draw.relativeTo: {workspace, file} which determines where the draw.directory value is appended to create an absolute path.

@hall
Copy link
Owner

hall commented Feb 18, 2023

I gave this some more thought and feels like the best answer here (for your example, at least) is to make the directory relative to the current file by default. I've done that in the linked PR; feel free to add feedback there.

In the more general case of supporting variable substitution, we can add more broad replacements (similar to how it's done in the cmake tools extension); it's not entirely straightforward but not incredibly difficult.

@hall hall linked a pull request Feb 18, 2023 that will close this issue
@hall hall removed a link to a pull request Feb 18, 2023
@yttriumz
Copy link
Author

yttriumz commented May 8, 2023

@hall Thank you so much for your effort!

Just for your information, this Markdown Paste extension seems to support predefined variables, many of which are the same as VSCode's ones. But they may not necessarily be retrieved from VSCode. I tested it and it works fine.

Since I'm not a JS/TS developer, I may not be able to help you much. But I hope Markdown Paste could provide you with some insights!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants