intentions icon indicating copy to clipboard operation
intentions copied to clipboard

Using intentions as the code actions package?

Open aminya opened this issue 3 years ago • 8 comments

I was thinking about using this package for our code actions. But the way decorations are handled causes issues such as #72.

What I want to suggest is to:

  • add a light bulb for the line where the user is (like Jetbrains or VSCode) instead of decorating all the available intensions in the whole editor

  • In case people want to see all the decorations when CTRL is held, we should switch to DisplayLayer instead of creating individual decorations for each. This would be much faster.

I am still confused about our solution for code actions, but it seems that the intentions package fits the problem better. 🤔

The alternative could be merging the code of the Intentions into Linter and retire Intentions. This would be the service API and how the actions are managed. Then we can use Linter-UI tooltips instead of the UI that intentions use. I prefer that we do not clutter the editor with code action decorations, so we need to adjust the UI of Linter-UI for this task.

Related: https://github.com/steelbrain/linter/issues/1705

aminya avatar Jun 15 '21 04:06 aminya

Would like to hear your ideas. @steelbrain @uzitech @lierdakil

aminya avatar Jun 15 '21 04:06 aminya

I like the light bulb idea. Also holding Ctrl, or some defined keys, to underline like hyper click would work too.

UziTech avatar Jun 15 '21 05:06 UziTech

Although it wasn't the best execution, I envisioned intentions to be the code actions package, while linter was one of the consumers that suggested the actions. There are a lot of code actions, some more proactively available than others:

  • Linter issues are available proactively for the whole file
  • Fancy language aware "find usages" and "refactor" could be a more reactive during-opening-dropdown action

But thinking about it now, this could be solved with a light-bulb style API. The user would see the highlight coming from linter and when they select that range, they could see the lightbulb coming from intentions. Thank you for working on this!

steelbrain avatar Jun 15 '21 05:06 steelbrain

All I ask is that the lightbulb icon be a rectangle with rounded corners and a proper shadow.

As opposed to something like this; an icon that is the shape of the bulb 💡 and looks like an emoji character inside the code Screenshot_20210615-080043__01.jpg

jeff-hykin avatar Jun 15 '21 13:06 jeff-hykin

Overall, I think it would be fine to show all of the light bulbs so long as they weren't visually obtrusive like other editors.

For example, a tiny gray outline of a bulb off in the gutter on the left side of the editor wouldn't be visual noise. If you were looking for it it would be there, but it wouldn't draw your attention away from the code. So from a cognitive load perspective, it would be fine to have 15 of those in one view.

Then just save the lit-up lightbulb for the current line, and have it dim to 50% opacity after 3 sec of inactivity.

jeff-hykin avatar Jun 15 '21 13:06 jeff-hykin

Instead of adding a lightbulb, wouldn't it be possible to reuse the "dots" from the linter-ui ? It would avoid having another gutter taking space on the side. For code actions on warning / errors the dots could be clickable, and for other actions, we could show a dot only for the current line.

k2d222 avatar Jun 15 '21 19:06 k2d222

Instead of adding a lightbulb, wouldn't it be possible to reuse the "dots" from the linter-ui ? It would avoid having another gutter taking space on the side. For code actions on warning / errors the dots could be clickable, and for other actions, we could show a dot only for the current line.

I support this.

Googling "IntelliJ Lightbulb" almost half the results are "how to disable IntelliJ lightbulb". And if people want to disable a useful feature, that probably means they screwed up the UI/UX. Keeping the UI as minimal as possible will probably avoid that problem.

jeff-hykin avatar Jun 16 '21 13:06 jeff-hykin

I don't think adding another gutter makes sense. I would prefer a lightbulb UI because it would produce much less visual distraction.

Instead of adding a lightbulb, wouldn't it be possible to reuse the "dots" from the linter-ui ? It would avoid having another gutter taking space on the side. For code actions on warning / errors the dots could be clickable, and for other actions, we could show a dot only for the current line.

Googling "IntelliJ Lightbulb" almost half the results are "how to disable IntelliJ lightbulb". And if people want to disable a useful feature, that probably means they screwed up the UI/UX. Keeping the UI as minimal as possible will probably avoid that problem.

The placement of the lightbulb is important here. I also don't think that putting the icon "on the code" is a good idea (what Intellij does). It should be in the gutter like Linter, but we shouldn't show all of the available code actions at once (that would mean that almost all the lines would have a lightbulb!).

My plan for now:

  • Add a "lightbulb button" in the gutter (like linter dots) only for the current line. It would be in the gutter, so not in the way of coding. Pressing the button should be the same as ALT+ENTER.

  • I will stick to the current method we are already using to show the available actions (adding underlines to the code itself which appears by holding CTRL).

aminya avatar Jun 16 '21 21:06 aminya