我可以让VS Code记住上次输入的任务字符串吗?

huangapple go评论129阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年6月30日 01:12:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76583247.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定