Skip to content

Commit

Permalink
sam: only skip the last empty match if it follows a newline
Browse files Browse the repository at this point in the history
This further tweaks the hack introduced to ignore the last match of ^
at the end of the file, see 1a15826.
  • Loading branch information
martanne committed Jan 25, 2021
1 parent 7b6c70e commit 80d0291
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 80d0291

Please sign in to comment.