inside / vim-search-pulse

Easily locate the cursor after a search
128 stars 8 forks source link

search_pulse#PulseFirst doesn't work correctly in operator-pending mode #23

Closed yongrenjie closed 2 years ago

yongrenjie commented 4 years ago

Hello,

First of all thanks for your work on this plugin. It's been incredibly useful so far.

There's one tiny hitch. When using / and ? as motions in operator-pending mode (e.g. c/<text>), extra text gets inserted. I have a small video showing this on a fresh installation of vim with no other plugins:

GIF of behaviour

This can be traced to the cmap command:

https://github.com/inside/vim-search-pulse/blob/9f8f473e3813bd76ecb66e8d6182d96bda39b6df/plugin/search_pulse.vim#L25

I don't know how to get this mapping to differentiate between command-line mode (e.g. /<text>) and operator-pending mode (e.g. c/<text>), but I figured out one way to fix this further downstream by modifying line 65 of

https://github.com/inside/vim-search-pulse/blob/9f8f473e3813bd76ecb66e8d6182d96bda39b6df/autoload/search_pulse.vim#L61-L70

to

if state() != 'o' && (t == '/' || t == '?')

I think the state() function was only added in vim 8.1.2047, though. And there's probably a better way to handle this which I don't know. :-)