Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
louis-vinchon opened this issue Jan 23, 2023 · 1 comment

Comments

@louis-vinchon
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants