aboutsummaryrefslogtreecommitdiff
path: root/sam.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2021-01-25 13:38:37 +0100
committerMarc André Tanner <mat@brain-dump.org>2021-01-25 14:02:31 +0100
commit80d0291b2ee9e7aae6683c973c263efbc02259c4 (patch)
tree1ce66f891e7ea9ee1d21b4287564de55466d4edd /sam.c
parent7b6c70ec6ea064aabd8e99b2d0d8ba285903bd0d (diff)
downloadvis-80d0291b2ee9e7aae6683c973c263efbc02259c4.tar.gz
vis-80d0291b2ee9e7aae6683c973c263efbc02259c4.tar.xz
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.
Diffstat (limited to 'sam.c')
-rw-r--r--sam.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sam.c b/sam.c
index 490d253..8e7b51f 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;