在 VS Code 中分组的好处?

发布于 2025-01-18 10:38:32 字数 420 浏览 3 评论 0原文

我最近开始了一门关于 c 语言编程的 Udemy 课程,当讲师详细介绍如何在 VS Code 中设置 ac 项目时,他必须浏览tasks.json 文件并添加以下代码。从一点点研究来看,似乎这是没有必要的,但我并不完全确定。如果有人能够详细说明 group>kind>build 和 isDefault>true 行的重要性,那就太棒了。

            "group": {
                "kind": "build",
                "isDefault": true

正如我所说,我尝试做一些在线研究,但没有什么是清楚的,并且用一种“呃,你应该知道这一点”的语气来表达,这确实超出了我的理解。

附带说明一下,这是我在堆栈溢出问题上提出的第二个问题,我希望得到一些有关格式的反馈。

I recently started a Udemy course on programming in c, and when the instructor was detailing how to set up a c project in VS Code, he had as go through the tasks.json file and add the following code. From a little bit of research, it seems that this is not necessary, but I am not entirely certain. If anyone could elaborate on the importance of the group>kind>build and isDefault>true lines in general, that would be fantastic.

            "group": {
                "kind": "build",
                "isDefault": true

As I said, I tried doing some online research, but nothing was clear, and was phrased in a "duh, you should know this", kind of tone, which really through off my understanding.

As a side note, this is my second ever question asked on stack overflow, and I would love some feedback on the formatting.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

庆幸我还是我 2025-01-25 10:38:32

VSCode 任务页面任务架构页面,所以我也很困惑。这是我目前的理解(可能有一些漏洞!)

组的类型可以是“test”“build”。您的选择决定了任务的列出或运行位置。

  • 当您从命令选项板中选择任务:运行测试任务命令时,将列出/运行“测试”任务。
  • 当您从命令选项板中选择任务:运行构建任务命令时,将列出/运行“构建”任务。默认情况下,它还有一个键盘快捷键 cmd+shift+b (Mac) 或 ctrl-shift-b (Windows/Linux)。

(在 Mac 上可以使用 cmd+shift+p 或在 Windows/Linux 上使用 ctrl+shift+p 显示命令面板。)

如果您只有一项特定类型的任务,或者有多个但只有一个具有 isDefault< /code> set,则在调用上述命令时运行该任务,否则会列出相关任务,您可以选择一个。在我的测试中,如果为同类的多个任务设置了 isDefault ,则它会被忽略。

kind 可以作为唯一值提供,也可以使用特定的“kind”键提供:

"group": "test"

或者

"group": {
    "kind": "test"
}

使用第二种形式的原因是它允许您指定 isDefault key 以及(参见上面的作用):

"group": {
    "kind": "test",
    "isDefault": true
}

This isn't particularly well documented on the VSCode Tasks page or tasks schema page, so I was confused too. Here's my current understanding (which may have some holes in!)

The group's kind can be either "test" or "build". Which you choose determine where the task is listed or run.

  • A "test" task is listed/run when you choose the Tasks: Run Test Task command from the command palette.
  • A "build" task is listed/run when you choose the Tasks: Run Build Task command from the command palette. By default, this also has a keyboard shortcut of cmd+shift+b (Mac) or ctrl-shift-b (Windows/Linux).

(The command palette can be shown with cmd+shift+p on Mac or ctrl+shift+p on Windows/Linux.)

If you only have one task of a certain kind, or have multiple but only one has isDefault set, then that task is run when the command above is invoked, otherwise the relevant tasks are listed and you can choose one. In my testing, isDefault is ignored if it's set for multiple tasks of the same kind.

The kind can either be provided as the only value or with the specific "kind" key:

"group": "test"

or

"group": {
    "kind": "test"
}

The reason to use the second form is that it allows you to specify the isDefault key as well (see above for what that does):

"group": {
    "kind": "test",
    "isDefault": true
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文