alacritty/alacritty

vi mode search wrap

bebecue opened this issue · 2 comments

Searching in vi mode wraps around

for example, search for foo and press n to go to next match

foo1
bar1
foo2
^
bar2

press n again

foo1
^
bar1
foo2
bar2

^ is the highlighted match

in vim, set nowrapscan will disable wrapping around and stop at the last match. This can be useful while searching from long-running command's output in terminal.

The same behavior can be achieved by pipeing to a pager like less and then searching from that. However, it doesn't work if the interested command is already running.

So it wound be nice if alacritty provides this function natively.

After some digging, I found it seems alacritty will always wraps around while searching at here

Will this feature also be useful to someone else?

Will this feature also be useful to someone else?

I think this is the key point here. I don't think it's worth it to add an option for that, but it should be simple to patch if you want it changed. If there's some huge interest I might reconsider, but I doubt that.

Just in case someone also want this, Here is the patch I got it working.

diff --git a/alacritty_terminal/src/term/search.rs b/alacritty_terminal/src/term/search.rs
index 585e191c..b4f4e8e2 100644
--- a/alacritty_terminal/src/term/search.rs
+++ b/alacritty_terminal/src/term/search.rs
@@ -156,6 +156,8 @@ impl<T> Term<T> {
             _ => end.sub(self, Boundary::None, 1),
         };
 
+        end.line = self.bottommost_line();
+
         let mut regex_iter = RegexIter::new(start, end, Direction::Right, self, regex).peekable();
 
         // Check if there's any match at all.