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

723 Views Asked by At

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?

1

There are 1 best solutions below

3
On BEST ANSWER

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: both issues are still open.

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