2017-12-02 530 views
2

在我的分機我有一個資源管理器視圖的欄上的一些按鈕:如何在VSCode擴展的資源管理器視圖中指定圖標的順序?

enter image description here

我怎麼可以指定按鈕顯示的順序?

我試圖在package.json的命令在commands屬性的順序發生變化:

"commands": [ 
    { 
    "command": "codeFragments.exportFragments", 
    "title": "Export all fragments to Json", 
    "icon": { 
     "light": "images/icon-export-light.png", 
     "dark": "images/icon-export-dark.png" 
    } 
    }, 
    { 
    "command": "codeFragments.importFragments", 
    "title": "Import fragments from Json", 
    "icon": { 
     "light": "images/icon-import-light.png", 
     "dark": "images/icon-import-dark.png" 
    } 
    }, 
    { 
    "command": "codeFragments.deleteAllFragments", 
    "title": "Delete all fragments", 
    "icon": { 
     "light": "images/icon-delete-light.png", 
     "dark": "images/icon-delete-dark.png" 
    } 
    } 
], 

還試圖在部分重新排序,其中我指定UI,在view/title屬性:

"view/title": [ 
    { 
    "command": "codeFragments.exportFragments", 
    "when": "view == codeFragments", 
    "group": "navigation" 
    }, 
    { 
    "command": "codeFragments.importFragments", 
    "when": "view == codeFragments", 
    "group": "navigation" 
    }, 
    { 
    "command": "codeFragments.deleteAllFragments", 
    "when": "view == codeFragments", 
    "group": "navigation" 
    } 
], 

而且當我推送命令訂閱時,還嘗試更改部分中的順序:

context.subscriptions.push(
    vscode.commands.registerCommand('codeFragments.exportFragments', exportFragments)); 
context.subscriptions.push(
    vscode.commands.registerCommand('codeFragments.importFragments', importFragments)); 
context.subscriptions.push(
    vscode.commands.registerCommand('codeFragments.deleteAllFragments', deleteAllFragments)); 

但是這些方法都不影響順序,按鈕總是以看似偶然的順序出現。

指定訂單的正確方法是什麼?

回答

0

調試vscode源一段時間後,我發現該溶液中,分選發生在這裏:https://github.com/Microsoft/vscode/blob/master/src/vs/platform/actions/electron-browser/menusExtensionPoint.ts#L365

基本上訂單號可以在@符號之後附加到命令的組的名稱,所以我必須做到以下幾點。

"view/title": [ 
    { 
    "command": "codeFragments.exportFragments", 
    "when": "view == codeFragments", 
    "group": "[email protected]" 
    }, 
    { 
    "command": "codeFragments.importFragments", 
    "when": "view == codeFragments", 
    "group": "[email protected]" 
    }, 
    { 
    "command": "codeFragments.deleteAllFragments", 
    "when": "view == codeFragments", 
    "group": "[email protected]" 
    } 
], 

,並找到在此之後,我試圖重新谷歌,事實證明這是正確的文件已經,但不知何故,我錯過了尋找它,當第一次:https://code.visualstudio.com/docs/extensionAPI/extension-points#_sorting-inside-groups

相關問題