vim-sneak icon indicating copy to clipboard operation
vim-sneak copied to clipboard

Labels are not shown for last partially displayed line

Open compleconomics opened this issue 3 years ago • 5 comments

Thanks a lot for the plugin. I generally work in label mode and have set display+=lastline in my .vimrc to show as much as possible of the last visible line.

In that case, sneak correctly highlights all my search results but does not attribute labels to any of the results in the last partially displayed line. If the display option is set to "" or if the last line is displayed entirely, everything works perfectly fine.

compleconomics avatar Oct 02 '21 02:10 compleconomics

Can't imagine what sneak logic would have this effect since the plugin just asks vim to search for text and highlight it. Can you try adding + 2 here: https://github.com/justinmk/vim-sneak/blob/95374ad3e4b5ef902854e8f4bcfa9a7a31a91d71/autoload/sneak/search.vim#L43-L45

like this:

return self._reverse ? line("w0") : (line("w$") + 2)

justinmk avatar Oct 03 '21 00:10 justinmk

Great! Works like a charm, thank you. +1 even seems to be enough to capture the remaining line.

compleconomics avatar Oct 03 '21 02:10 compleconomics

A slight problem with this simple solution is that it labels invisible positions now, which might result in surprising behaviour - isn't there a way to check whether a match is actually on screen, before the @@@ part?

ggandor avatar Oct 03 '21 09:10 ggandor

A slight problem with this simple solution is that it labels invisible positions now, which might result in surprising behaviour

yeah :(

isn't there a way to check whether a match is actually on screen, before the @@@ part?

idk, grateful if anyone finds a hint.

justinmk avatar Oct 04 '21 00:10 justinmk

idk, grateful if anyone finds a hint.

Checking the screenpos of the matches could be a solution - at least that is what I thought. The problems are:

  1. screenpos is incredibly slow for lots of matches (this can be mitigated with some kind of bisecting approach though).
  2. It doesn't actually work. (IMO, ignoring these partial lines can be considered buggy, or at the very least surprising behaviour from screenpos().)

ggandor avatar Apr 26 '22 09:04 ggandor