From 7f87280cd539c26a9b088cca2de895dd86b60449 Mon Sep 17 00:00:00 2001
From: nicm <nicm>
Date: Tue, 9 Mar 2021 13:07:50 +0000
Subject: [PATCH] Allow cursor to be just after match if copying, GitHub issue
 2602.

---
 window-copy.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/window-copy.c b/window-copy.c
index 0723855d..3fc7ad3e 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -3366,8 +3366,11 @@ window_copy_match_at_cursor(struct window_copy_mode_data *data)
 	cy = screen_hsize(data->backing) - data->oy + data->cy;
 	if (window_copy_search_mark_at(data, data->cx, cy, &at) != 0)
 		return (NULL);
-	if (data->searchmark[at] == 0)
-		return (NULL);
+	if (data->searchmark[at] == 0) {
+		/* Allow one position after the match. */
+		if (at == 0 || data->searchmark[--at] == 0)
+			return (NULL);
+	}
 	window_copy_match_start_end(data, at, &start, &end);
 
 	/*