vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 0b26b2c3efb86da0877dc9ec98e7bc327c113dfd
parent 4aef36bd8d7e9b118ec05b811fcac5af2815a350
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Mon, 25 Jan 2021 13:38:37 +0100

sam: only skip the last empty match if it follows a newline

This further tweaks the hack introduced to ignore the last match of ^
at the end of the file, see d26ac2103119d7b809c15b980eb34f5974c5fac9.

Diffstat:
Msam.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sam.c b/sam.c @@ -1424,7 +1424,8 @@ static int extract(Vis *vis, Win *win, Command *cmd, const char *argv[], Selecti * matches the zero-length string immediately after a * newline. Try filtering out the last such match at EOF. */ - if (end == match[0].start && start > range->start) + if (end == match[0].start && start > range->start && + text_byte_get(txt, end-1, &c) && c == '\n') break; } start = match[0].end;