Skip to content

Support for Variable Substitution #2

@yttriumz

Description

@yttriumz

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

Activity

hall

hall commented on Feb 10, 2023

@hall
Owner

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

hall commented on Feb 10, 2023

@hall
Owner

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

hall commented on Feb 18, 2023

@hall
Owner

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.

linked a pull request that will close this issuerework directory to be relative to file #4on Feb 18, 2023
yttriumz

yttriumz commented on May 8, 2023

@yttriumz
Author

@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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @hall@yttriumz

        Issue actions

          Support for Variable Substitution · Issue #2 · hall/draw