You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How could I handle OnClick ad hover events on gutter icons, similar to how breakpoints does?
The intention was to connect it with a decorator (previously created with vscode.window.createTextEditorDecorationType) so the user should click or hover on the gutter and create/destroy the decorator assigned to the line where the user clicked.
Reacted by Vladimir Fokow, Benjamin Hoover, Arun Tejasvi Chaganty, Matt Legrand, Syl, Moogi, Surbhi Jain, Matt Ball, Chris Kelly, Joel Galenson and 41 more
Related to #5455 (OnClick event on Gutter) but that issue was closed without a solution. Also related to #179725 (Support multiple decorations in editor glyph margin).
Here's how such a feature could look like. E.g. this is how the tests in VSCode can be invoked via a gutter icon (that supports a text field on hover as well as a right-click context menu):
However, in this case we don't have to additionally support setting breakpoints at that line (since the "Run test" icons are placed at the method signature and not inside a method body). Generally, the breakpoint functionality should of course not suffer, so one solution would be to expand the width of the gutter pane to support multiple icons (that could be additionally overlap partially to save a bit of space. The hovered icon could then always pop into the foreground to be fully visible). See #179725 for further proposals regarding how to support multiple decorations in the "editor glyph margin".
I've also noticed that the GitHub Pull Requests VSCode extension manages to show a colored strip as well as a button to the right side of the editor line numbers:
Show recording
However, this button appears all the time, not just on hover. I don't know how this area is called in the VSCode API. But it might be worth to look into the respective repo for the extension to find out how they do it. This could be a solution for those who want to have a clickable button on lines in the editor. -> Edit: Nope, after some search, the plus icon used there is baked into vscode and the functionality provided by the comments API. That means you can unfortunately not define your own buttons there, and also not with onclick actions.
Reacted by Tanveer Gill, Anurag Sharma, Gegenwurm, Florian, Stawroula Lazaridou and Maxim
Some more thoughts on this since this features request comes with challenges regarding multiple icons.
🎈 Max number of icons next to each other
When this feature is available (let's call it "gutter action icon"), in the worst case, we get many, many extension that might want to register such a gutter action icon on the same line (because maybe that line is the line where a function is defined). Obviously, 20 icons next to each other is not practical. So there has to be a limit on how many we want to show at max. Maybe 2 or 3 would be ok. See IntelliJ as comparison (here 3 or even 4 icons next to each other).
🎈 Remaining icons in popup on hover
The remaining icons could be shown on hover over the existing gutter icon. In this example, the action is all provided by the same plugin, therefore just one icon is shown directly. On hover, all of the action items are shown (even the one that was directly visible).
If we mix different kinds of gutter action icons, this is how it looks like:
If more than 4 different types of icons are shown, IntelliJ just cuts them off and doesn't show any popup for the rest. We should avoid this at all cost to avoid frustrated users who wonder where the icon is that an extension promised to show up.
🎈 Variable width
Maybe the max number of icons could become a user setting ($k \in {1,2, 3, 4}$). Additionally, maybe there could be a feature to allow to drag the right boundary line of the gutter area and drag it to the left/right to intuitively adjust $k$, i.e. allow a natural shrinking/enlarging of that area.
🎈 Icon priority
Sublime Text users also wish this feature: specify the gutter action icon order, e.g. you might use one extension frequently and want its icon to always be in the front. Priority could mean:
let users weight the icons, but just à la: "I want this icon to be visible directly more often compared to other ones, which should be hidden behind the popup if necessary".
let users weight the icons rigorously à la: "This is my exact order I always want".
As a bonus, it'd be cool, if users could also drag the icons to another position manually to adjust the priority. E.g. you could drag an icon to the very front if you need it more frequently.
🎈 Disable icons
IntelliJ allows to disable some icons, e.g. if you find that some icons are not really necessary. The settings for this could be shown in a similar fashion to hiding activity bar icons (by right-clicking):
Reacted by Marc Auberer, Hugues Verlin, Gegenwurm, Florian, Stawroula Lazaridou, fosterfarrell9, Marcelo Glasberg, Tobias Hochgürtel, Ante Prkačin, James Blackburn and 3 more
Activity
marcglasberg commentedon Jul 28, 2024
Related to #5455 (OnClick event on Gutter) but that issue was closed without a solution. Also related to #179725 (Support multiple decorations in editor glyph margin).
marcglasberg commentedon Jul 28, 2024
Joyce Er (@joyceerhl) please, can I set a zIndex for my decorations, or this is not exposed to the extensions API? #179910
Splines commentedon Nov 2, 2024
Here's how such a feature could look like. E.g. this is how the tests in VSCode can be invoked via a gutter icon (that supports a text field on hover as well as a right-click context menu):
However, in this case we don't have to additionally support setting breakpoints at that line (since the "Run test" icons are placed at the method signature and not inside a method body). Generally, the breakpoint functionality should of course not suffer, so one solution would be to expand the width of the gutter pane to support multiple icons (that could be additionally overlap partially to save a bit of space. The hovered icon could then always pop into the foreground to be fully visible).
See #179725 for further proposals regarding how to support multiple decorations in the "editor glyph margin".
I've also noticed that the GitHub Pull Requests VSCode extension manages to show a colored strip as well as a button to the right side of the editor line numbers:
Show recording
However, this button appears all the time, not just on hover. I don't know how this area is called in the VSCode API. But it might be worth to look into the respective repo for the extension to find out how they do it. This could be a solution for those who want to have a clickable button on lines in the editor. -> Edit: Nope, after some search, the plus icon used there is baked into vscode and the functionality provided by the comments API. That means you can unfortunately not define your own buttons there, and also not with onclick actions.
Splines commentedon Nov 3, 2024
To justify the popularity of this request, here are some links:
& Is there any way to bookmark w/ mouse on the gutter (like breakpoints)?
Possible Alternative (but not really a good substitute):
hyoretsu commentedon Jan 20, 2025
Any news? Gutter functionality is really useful, and would be even more for extensions.
Splines commentedon Jan 20, 2025
Some more thoughts on this since this features request comes with challenges regarding multiple icons.
🎈 Max number of icons next to each other
When this feature is available (let's call it "gutter action icon"), in the worst case, we get many, many extension that might want to register such a gutter action icon on the same line (because maybe that line is the line where a function is defined). Obviously, 20 icons next to each other is not practical. So there has to be a limit on how many we want to show at max. Maybe 2 or 3 would be ok. See IntelliJ as comparison (here 3 or even 4 icons next to each other).
🎈 Remaining icons in popup on hover
The remaining icons could be shown on hover over the existing gutter icon. In this example, the action is all provided by the same plugin, therefore just one icon is shown directly. On hover, all of the action items are shown (even the one that was directly visible).
If we mix different kinds of gutter action icons, this is how it looks like:
If more than 4 different types of icons are shown, IntelliJ just cuts them off and doesn't show any popup for the rest. We should avoid this at all cost to avoid frustrated users who wonder where the icon is that an extension promised to show up.
🎈 Variable width
Maybe the max number of icons could become a user setting ($k \in {1,2, 3, 4}$ ). Additionally, maybe there could be a feature to allow to drag the right boundary line of the gutter area and drag it to the left/right to intuitively adjust $k$ , i.e. allow a natural shrinking/enlarging of that area.
🎈 Icon priority
Sublime Text users also wish this feature: specify the gutter action icon order, e.g. you might use one extension frequently and want its icon to always be in the front. Priority could mean:
As a bonus, it'd be cool, if users could also drag the icons to another position manually to adjust the priority. E.g. you could drag an icon to the very front if you need it more frequently.
🎈 Disable icons
IntelliJ allows to disable some icons, e.g. if you find that some icons are not really necessary. The settings for this could be shown in a similar fashion to hiding activity bar icons (by right-clicking):
Further links
wangjian1106 commentedon Sep 15, 2026
Any news?
glyphMarginsupport to extensions #47559 as a duplicate of this issue