facelessuser / ColorHelper

Sublime plugin that provides helpful color previews and tooltips
https://facelessuser.github.io/ColorHelper/
MIT License
254 stars 30 forks source link

Messed up origin/end hotkeys #255

Closed jerefrer closed 1 year ago

jerefrer commented 1 year ago

Description

Since I updated Sublime after a long time away form the Internet, I'm having issue with this plugin regarding the origin/end hotkeys that are behaving unreliably and it is quite frustrating.

When I hit the origin or end hotkeys when my cursor is below any color code that is recognized by ColorHelper (and for which a color square is therefore shown), then instead of having my cursor go to the beginning or end of the line like it should, it instead jumps to the beginning or end of the previous line.

When I uninstaller this package then everything comes back to normal.

This is quite a shame since this package has been so useful to me for so long, but at the moment I'm considering removing it since not being able to use my beloved hotkeys is so painful and frustrating ...

Thanks for reading, hope you can find a fix :)

Support Info

Steps to Reproduce Issue

  1. Install ColorHelper on latest Sublime
  2. Open a CSS file having at least one color code
  3. Place your cursor below that line
  4. Hit the Origin hotkey
  5. See that your cursor is on the beginning of the previous line instead of the one the cursor was on before hitting Origin.
facelessuser commented 1 year ago

I know you are experiencing this with ColorHelper, but this is not a ColorHelper bug, but a Sublime Text bug. We do not intercept cursor movement. Sublime is incorrectly calculating the movement of cursors when a phantom is present.

So, how do I know it isn't ColorHelper? Because I can completely disable ColorHelper and reproduce this issue with other packages that inject phantoms. I installed LSP-CSS which injects its own color previews, and what happens? The same behavior that you are experiencing, but only on Windows (and maybe Linux, but I haven't tested).

One thing to note, this is not an issue on Mac, and I think the reason is that since mac doesn't have a home or end key there appears to be no Sublime key mapping for move_to to the eol or bol. They just let mac do it themselves it seems.

So, can this be mitigated? Well, to some extent, yes.

You can try setting "preview_on_select": true, in ColorHelper. This will only show a preview when you've selected the color (or the cursor is on the color). This prevents phantoms from being injected by default, and only appear if you are on the color. Now jumping to the start or end will work. But make no mistake, this needs to be fixed in Sublime Text. I would create an issue with SublimeHQ.

facelessuser commented 1 year ago

I created the Sublime issue: https://github.com/sublimehq/sublime_text/issues/6098

facelessuser commented 1 year ago

In the Sublime issue I demonstrate how to reproduce without ColorHelper.

jerefrer commented 1 year ago

Woah thanks for the quick reply, finding the actual source of the problem and then even creating the issue. I couldn't have found this myself !

Have a great evening, hopefully they'll fix this soon too :)

And thanks for the temporary workaround, that'll help in the meantime.