防止在VS Codium中执行命令序列的异步顺序
我如何控制 multicommand 延伸?它的行为就像它并行执行,而我希望它们接一个地执行。
我有一个具有以下结构的项目:
/home/user/myproject/dir1/problem1.py
/home/user/myproject/dir1/problem1.txt
/home/user/myproject/dir1/problem2.py
/home/user/myproject/dir1/problem2.txt
...
/home/user/myproject/pointer.txt
pointer.txt
包含文本: dir1/Quards2
。
我想按快捷方式,并执行一系列操作:
- 创建下一个问题文件
- 对修改指针。txt指向新文件,
- 在我设置的编辑器中打开它们
。
在 settings.json
中我定义了名为“ OpenPointEdproblembaylayout”的命令序列(因为能够轻松重复使用它):
"multiCommand.commands": [
{
"command": "multiCommand.openPointedProblemLayout",
"sequence": [
{ "command": "htmlRelatedLinks.openFile",
"args": {
"file": "${command:mypointer}.py",
"method": "vscode.open",
"viewColumn": 1,
"command": {
"mypointer": {
"command": "extension.commandvariable.file.content",
"args": {
"fileName": "${workspaceFolder}/pointer.txt"
}
}
}
}
},
{ "command": "htmlRelatedLinks.openFile",
"args": {
"file": "${command:mypointer}.txt",
"method": "vscode.open",
"viewColumn": 2,
"command": {
"mypointer": {
"command": "extension.commandvariable.file.content",
"args": {
"fileName": "${workspaceFolder}/pointer.txt"
}
}
}
}
},
]
},
]
在 tasks.json
我创建了一个shell命令定义,创建了一个shell命令一个新的.py和.txt对,还更改了指针:
{
"version": "2.0.0",
"tasks": [
{
"label": "create_new_problem_files_pair",
"type": "shell",
"command": "python /home/user/scripts/create_new_problem_files_pair.py \"${file}\""
},
],
}
in keybindings.json
i定义了执行操作(创建文件并打开文件)和numpad5(仅打开它们)的快捷方式numpad2(仅打开它们):
{
"key": "numpad2",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
{
"command": "workbench.action.tasks.runTask",
"args": "create_new_problem_files_pair"
},
{
"command": "multiCommand.openPointedProblemLayout"
},
]
}
},
{
"key": "numpad5",
"command": "extension.multiCommand.execute",
"args": { "command": "multiCommand.openPointedProblemLayout" },
},
现在,当我按NUMPAD2时,创建了两个新文件:
/home/user/myproject/dir1/problem3.py
/home/user/myproject/dir1/problem3.txt
然后在布局中打开两个文件 (意味着命令实际运行),但错误的文件。它们是问题。
我现在检查了pointer.txt的内容,它实际上包含 dir1/Quards 3
。当我按NUMPAD5时,它们会正确打开。
为什么VS Codium使用指针的先前内容,而在运行命令时,它应该已经采用新内容?它看起来像VS代码并行执行命令序列,而不是序列它们。
我做错了吗?这是配置或VS代码本身的问题,还是在多功能扩展中的问题?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过避免使用任何扩展来解决问题。可以通过任务定义命令序列。参见 https://stackoverflow.com.com/a/72201981/7869636
in
keybindings.json.json.json.json define:
并且在
任务中
。代码>。
I have solved the problem by avoiding usage of any extensions. A command sequence can be defined via Tasks. See https://stackoverflow.com/a/72201981/7869636
In
keybindings.json
I define:And in
tasks.json
I defined the whole things:This approach has a benefit that it defines these tasks in a scope of that project's workspace, and not globally in
setting.json
.