justinmk / vim-sneak

The missing motion for Vim :athletic_shoe:
http://www.vim.org/scripts/script.php?script_id=4809
MIT License
3.26k stars 88 forks source link

Labels are not shown for last partially displayed line #283

Open compleconomics opened 3 years ago

compleconomics commented 3 years ago

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.

justinmk commented 3 years ago

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)
compleconomics commented 3 years ago

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

ggandor commented 3 years ago

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?

justinmk commented 3 years ago

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.

ggandor commented 2 years ago

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().)