winston0410 / range-highlight.nvim

An extremely lightweight plugin (~ 120loc) that hightlights ranges you have entered in commandline.
MIT License
203 stars 5 forks source link

anything in cmd line highlights the current line #4

Closed rudotriton closed 3 years ago

rudotriton commented 3 years ago

Changes introduced in #3c8ca3 result in highlighting the current line when anything is written to the command line.

This somehow becomes an issue with <Plug> commands. I use chaoren/vim-wordmotion so motions such as w, b, and e are remapped to Plug commands. Every time I press any of those keys, the current line is highlighted for a fraction of a second.

https://user-images.githubusercontent.com/14181026/119231076-ac135980-bb27-11eb-94bd-bf9709c44917.mov

winston0410 commented 3 years ago

Hi thank you for reporting. I will come back to you after I have checked out chaoren/vim-wordmotion. I am clueless right now for such behavior as that commit should only affect mark range.

winston0410 commented 3 years ago

I have just updated the plugin to 0.6.0. Can you check if it works for you now?

akinsho commented 3 years ago

@winston0410 I've also been experiencing this issue and just tried the latest commit and still see this issue just typing :s or any other character immediately triggers highlighting the current line.

EDIT: as well as the issue with word motion which I also use

winston0410 commented 3 years ago

I assumed command without range is targeting the current line, and I guess you are right and this need to be fixed. But some command really target the current line, so I guess I have to make I whitelist for commands

@akinsho have you experienced the flicker of highlighting the current line? I think that one is really the bug because it should have been caught by the cache.

akinsho commented 3 years ago

@akinsho have you experienced the flicker of highlighting the current line? I think that one is really the bug because it should have been caught by the cache.

@winston0410 yep it flickers every time I use w which is mapped to the word motion w mapping,

regarding handling of the range and which commands trigger highlighting to my mind I'd assume that until someone has pressed enough characters to make up a valid range nothing should be highlighted e.g. typing :select is not a range. Is there a way to check on key press if the current entry is actually a valid range before highlighting?

winston0410 commented 3 years ago

@akinsho I have just committed and the 0.6.1 should solve the flickering issue.

For the unnecessary current line highlight, I think we need to create a whitelist or a blacklist for command for highlighting, because some commands (like :d or :y) targets the current line while some don't. Solely using range is not accurate enough there. Do you have any idea how can I get that list? Is there a existing one?

I will try to support that in next minor update.

akinsho commented 3 years ago

@winston0410 just tried it out and it didn't seem to make a difference still flickers. Can you try installing word motion on your end and seeing the behaviour with it installed. Might give more of an idea on why the fixes aren't working

winston0410 commented 3 years ago

@akinsho I have just pushed 0.7.0 for filtering in command that would be highlighted when range does not exist, which should do the trick. If it still doesn't work, I will try and install word motion during weekend.

rudotriton commented 3 years ago

It still doesn't fix it, but here's some more info. The command that actually gets called looks something like this call wordmotion#motion(v:count1, 'n', 'b', 0, []) and the ( seems to cause the highlighting to trigger.

winston0410 commented 3 years ago

thanks @rudotriton for that information. I will try install wordmotion tonight and try it out. Btw there seems not the be a variant of camelCase wordMotion in nvim?

winston0410 commented 3 years ago

@rudotriton I have installed that plugin, tried out entering call wordmotion#motion(v:count1, 'n', 'b', 0, []) and no highlight occur. I think this is tackled by 0.7.1. Can you confirm on your end as well?

akinsho commented 3 years ago

@winston0410 that seems to have fixed the word motion issue 🚀 and not seeing current line highlighted for normal characters any more. Thanks so much for persevering and fixing it 👍🏾

winston0410 commented 3 years ago

Awesome. Thank for tolerating my previous error. Closing this issue now.

rudotriton commented 3 years ago

I'm not seeing the odd highlighting, so I think you've done it. Thank you so much.