如何订购内联视图工具栏图标?

How to order inline view toolbar icons?

在我编写 VS Code 扩展时,我希望在刷新图标的右侧显示“+”图标。但是,package.json 中的排序似乎并不代表呈现的顺序。我总是在刷新图标的左边看到添加图标。

这是视图定义的片段:

{
    "commands": [
      {
        "command": "refresh-jobs",
        "title": "Refresh",
        "icon": {
          "light": "resources/light/refresh.svg",
          "dark": "resources/dark/refresh.svg"
        }
      },
      {
        "command": "add-job",
        "title": "Add",
        "icon": {
          "light": "resources/light/add.svg",
          "dark": "resources/dark/add.svg"
        }
      },
    ],
    ...
    "view/item/context": [
        {
          "command": "refresh-jobs",
          "group": "inline",
          "when": "viewItem == jobgroup"
        },
        {
          "command": "add-job",
          "group": "inline",
          "when": "viewItem == jobgroup"
        },
    ]
}

有什么帮助吗?谢谢!

我发现了这个老问题:Add custom ordering to title menu items.,它建议您执行以下操作:

There is way to define the order and I am surprised we haven't properly documented that... What you can do is adding an order to the group-attribute like so group: name@number. In your case

{    
 "command": "md-shortcut.toggleBold",
  "when": "editorLangId == 'markdown'",
  "group": "2_markdown_1@1"  
}

我在这里看到:menu example @n 语法用于对菜单条目进行排序,但我上面提到的问题似乎暗示它也会对标题栏中的图标进行排序。试试这个:

    "view/item/context": [
        {
          "command": "refresh-jobs",
          "group": "inline@1",
          "when": "viewItem == jobgroup"
        },
        {
          "command": "add-job",
          "group": "inline@2",
          "when": "viewItem == jobgroup"
        },
    ]

"group": "inline@1", 注意@1

让我知道它是否适合你。