iconsvscode-extensionsgutter

In my VS Code extension, how to add gutter icon with action?


I'm working on VSCode extension and need to add actions to gutter icons. Right now I'm adding gutter icon

    const documentDecorationType = vscode.window.createTextEditorDecorationType({
        gutterIconPath: context.asAbsolutePath('media/link.svg')
    });
    
    editor.setDecorations(documentDecorationType, [
        {   
            range: new vscode.Range(new vscode.Position(document.start_line, 0), new vscode.Position(document.end_line, 0)),
        }               
    ]); 

How can I add an action/command to icon?


Solution

  • It doesn't look like you can add a command directly to a gutter icon. See OnClick event on Gutter and Allow clicking gutter icon: the second issue is still open.

    And see OnClick and hover events on gutter icons as mentioned in the comments by @Splines which is getting more activity than the open issue above.

    You may be able to add it as a command in a hover though (still trying to get it to work...)