pocco81 / high-str.nvim

🦎 A NeoVim plugin for highlighting visual selections like in a normal document editor!
GNU General Public License v3.0
306 stars 2 forks source link

The `HSRmHighlight` command (without arguments) doesn't behave as expected / documented #17

Open louis-vinchon opened 1 year ago

louis-vinchon commented 1 year ago

Immediate issue

The HSRmHighlight documentation states:

:HSRmHighlight <rm_all>: If the rm_all argument is given, removes all the highlighting in the current buffer. If not, does the same but for every line in visual selection.

Removing all highlights works fine.

However visually selecting a range and runing the function throws the following error:

E481: No range allowed

I tried both visual line and line selections, and both throw the same error.


I just realized that it was an issue with the Highlight command as well: the command doesn't work on what is currently visually selected; but it works when nothing is selected, it will highlight what was last selected.

Reproduction steps:

  1. Visually select anything.
  2. Run :HSHighlight 1 (the command line should show :'<,'>HSHighlight 1).
  3. E481: No range allowed

  4. You should be back in normal mode at this point, run :HSHighlight 1 again.
  5. What was previsouly selected is now properly highlighted.

Other unexpected behavior

:HSRmHighlight will apparently remove more than what was last selected:

Removing line-wise highlights

Reproduction steps:

  1. Highlight line n with color X (<S-v> mapping).
  2. Highlight line n + 1 with color Y
  3. Run :HSRmHighlight without anything visually selected.
  4. Both lines should be erased except the first character of line n (in color X). it should only have erased the last thing we selected (the last highlight, in color Y).

Removing "regular" highlights

Reproduction steps:

  1. Highlight a few characters on a line with color X.
  2. Highlight some other characters on that line with color Y.
  3. Run :HSRmHighlight without anything visually selected.
  4. The entire line highlights are erased. Both X and Y colors.

The relative position of the highlighted ranges does not matter.


Bonus

It appears that the :HSRmHighlight command also erases highlights from other plugins such as indent-blankline, fortunately that's a temporary issue.

WhiteBlackGoose commented 1 year ago

Visually select anything. Run :HSHighlight 1 (the command line should show :'<,'>HSHighlight 1).

That's the thing. After you type :, you get '<,'>. You need to press Ctrl+u to remove it and type the rest of the command.

In bindings, use :<C-u>HSHighlight and same for removal