英文:
Can I make VS Code remember the last input string to a task?
问题
我创建了一个任务,调用了我的自定义构建系统。它能够工作,但每次运行时都必须重新输入目标名称字符串。我希望它能记住上次的输入并自动填充,而不是使用默认值。是否有方法可以实现这一点?
// 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"
},
]
}
英文:
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"
},
]
}
答案1
得分: 1
你可以使用扩展 Command Variable 和命令 extension.commandvariable.promptStringRemember
> 如果你已经给了一个关键属性,输入框将会被预填充为:
>
> * 会话中的第一次调用:默认值
> * 会话中的下一次调用:上一次的值
英文:
you can use the extension 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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论