Closed quark-zju closed 3 years ago
Thanks! This was on my TODO-list.
Rather than making this a config option, I think it would be better if these were new keybinding actions and match movements (Action::NextMatchOnScreen
=> MatchMotion::NextOnScreen
, etc.). We can change the default bindings to use the OnScreen
variants to match less, but if you also want the behaviour of moving exactly through the matches (even if you've scrolled away to look at something else briefly), we can have an extra shortcut for that.
Looks good!
Not for this change, but a difference with less that this highlights is that we always jump so that the target line is in the center, which can look odd for "next in screen" as it may make us jump in the opposite direction to recenter things.
I think the way to fix that is to make scroll_to
take an option for how we want to scroll to a particular target. The options should be AtTop
, AtCenter
, AtBottom
and MakeVisible
. The first 3 should be fairly self explanatory. MakeVisible
should prefer not to scroll, but if the target line is off-screen, then scroll until it becomes visible.
(BTW, another thing that needs to be implemented is dealing with matches that are not in the visible part of the line (either off to the right if wrapping is off, or not on the first line if wrapping is on. This is on my TODO list, but I haven't had time yet)
Add a config option to control whether search should follow the current screen (line position).
The default is yes, to match less/vim behavior.