From 80d0291b2ee9e7aae6683c973c263efbc02259c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Mon, 25 Jan 2021 13:38:37 +0100 Subject: [PATCH] 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 1a158268c7693b00bf43c7e81034816d8d00358c. --- sam.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sam.c b/sam.c index 490d253ef..8e7b51f04 100644 --- 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;