visual-studio-code

Can I make VS Code remember the last input string to a task?


I created a task that invokes my custom build system. It works, but every time I run it it I have to retype the target name input string. I'd like it to remember the last one and autofill that, not the default value. Is there a way to do that?

// tasks.json
{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "buildsys",
            "command": "buildsys build ${input:target}",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "options": {
                "env": {
                    "PATH": "${env:PATH}:/Dev/BuildSystem/bin"
                }
            },
            "problemMatcher": ["$gcc"],
            "detail": "My custom build task"
        }
    ],

    "inputs": [
        {
            "id": "target",
            "description": "Target:",
            "default": "FooApp",
            "type": "promptString"
        },
    ]
}

Solution

  • you can use the extension I made Command Variable and the command extension.commandvariable.promptStringRemember

    If you have given a key attribute the Input Box will be prefilled with:

    • first call in session: the default value
    • next call in session: the previous value