vscode-ext-commands

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

VS Code extension command contribution

VS Code扩展命令贡献

This skill helps you to contribute commands in VS Code extensions
本技能可帮助你在VS Code扩展中贡献命令

When to use this skill

何时使用本技能

Use this skill when you need to:
  • Add or update commands to your VS Code extension
当你需要以下操作时使用本技能:
  • 为你的VS Code扩展添加或更新命令

Instructions

说明

VS Code commands must always define a
title
, independent of its category, visibility or location. We use a few patterns for each "kind" of command, with some characteristics, described below:
  • Regular commands: By default, all commands should be accessible in the Command Palette, must define a
    category
    , and don't need an
    icon
    , unless the command will be used in the Side Bar.
  • Side Bar commands: Its name follows a special pattern, starting with underscore (
    _
    ) and suffixed with
    #sideBar
    , like
    _extensionId.someCommand#sideBar
    for instance. Must define an
    icon
    , and may or may not have some rule for
    enablement
    . Side Bar exclusive commands should not be visible in the Command Palette. Contributing it to the
    view/title
    or
    view/item/context
    , we must inform order/position that it will be displayed, and we can use terms "relative to other command/button" in order to you identify the correct
    group
    to be used. Also, it's a good practice to define the condition (
    when
    ) for the new command is visible.
VS Code命令必须始终定义一个
title
,与其分类、可见性或位置无关。我们针对每种类型的命令使用了一些模式,各有特点,如下所述:
  • 常规命令:默认情况下,所有命令都应在Command Palette中可访问,必须定义一个
    category
    ,不需要
    icon
    ,除非该命令将在Side Bar中使用。
  • Side Bar命令:其名称遵循特殊模式,以下划线(
    _
    )开头并以
    #sideBar
    结尾,例如
    _extensionId.someCommand#sideBar
    。必须定义一个
    icon
    ,可以有也可以没有
    enablement
    规则。仅在Side Bar中使用的命令不应在Command Palette中可见。将其贡献到
    view/title
    view/item/context
    时,我们必须指定它将显示的顺序/位置,并且可以使用“相对于其他命令/按钮”的术语来帮助你确定要使用的正确
    group
    。此外,定义新命令可见的条件(
    when
    )是一种最佳实践。