Skip to content

Substitute variables in launch configuration keys (and not only in values) #34059

Closed

Description

@frost-see
  • VSCode Version: 1.15.1
  • OS Version: Win7

Feature description:
It would be nice to use the environment variable $ {env: variable} in launch.json sourceFileMap, like using the built-in variable $ {workspaceRoot}.

The present situation is that we can write $ {env: variable} in sourceFileMap, but it is not replaced by real path like $ {workspaceRoot}.

So, when debugging with cpptools extension for c++ program,vscode pops up the following message box:

Error: Unable to open 'main.cpp': File not found (\usr1\pDTest\demo\main.cpp). Create File Cancel

The sourceFileMap is very simple:

"sourceFileMap": {
    // "remote": "local"
    
    // This way works well
    // "/usr1/pDTest/demo" : "D:\\demo"
    
    // This way does not work
    "/usr1/{env:USERNAME}/demo" : "D:\\demo"
},

This feature is useful for collaborative development of multiple programmers. we can push launch.json on git repo, and do not need everyone to modify it.

Activity

  1. added
    feature-request
    debug
    on Sep 9, 2017
  2. isidorn commented on Sep 12, 2017

    @isidorn

    Yes, currently we are only resolving the values of objects in the configuration, not the keys (which is what you want).
    We accept PRs that elegantly fix this, code pointer https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/services/configurationResolver/node/configurationResolverService.ts#L194

  3. changed the title [-]Feature require: sourceFileMap support environment variable like ${workspaceRoot}[/-] [+]Substitute variables in launch configuration keys (and not only in values)[/+] on Sep 29, 2017
  4. OkkeHendriks commented on Nov 1, 2017

    @OkkeHendriks

    nbstar I was wondering if you have found a workaround for this?

  5. weinand commented on Nov 14, 2017

    @weinand
    Contributor

    Isidor Nikolic (@isidorn) since VS Code's use of JSONs sometimes has values on the left hand side (as keys), we should consequently support variable substitution there too (and I've targeted this for "On Deck").

    I assume this feature is low-hanging fruit?

  6. isidorn commented on Nov 14, 2017

    @isidorn

    Andre Weinand (@weinand) should not be too complex

  7. added
    verification-needed
    on May 11, 2018
  8. isidorn commented on May 11, 2018

    @isidorn

    Dirk Bäumer (@dbaeumer) note that we now also resolve keys not only values in configuraitons since this also affects tasks.

  9. aeschli commented on May 31, 2018

    @aeschli
    Contributor

    Verified that variables are substituted in both values and keys:

            {
                "type": "node",
                "request": "launch",
                "name": "Launch Program",
                "program": "${workspaceFolder}/index.js",
                "env": {
                    "foo${lineNumber}": "${workspaceFolder}"
                }
            },
    
  10. added
    verified
    and removed
    verification-needed
    on May 31, 2018
  11. locked and limited conversation to collaborators on Jun 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

debugfeature-requestrelease-notesverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions