From 0c374868ca34cef826e15e7984300f0292b314d8 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 21 Mar 2024 11:26:28 +0000 Subject: [PATCH] Do not consider a selection present if it is empty, from Michael Grant (GitHub issue 3869). Also a typo fix from GitHub issue 3877. --- screen.c | 2 +- window-copy.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/screen.c b/screen.c index 267a50b9..de072d1a 100644 --- a/screen.c +++ b/screen.c @@ -384,7 +384,7 @@ screen_resize_y(struct screen *s, u_int sy, int eat_empty, u_int *cy) /* * Try to pull as much as possible out of scrolled history, if - * is is enabled. + * it is enabled. */ available = gd->hscrolled; if (gd->flags & GRID_HISTORY && available > 0) { diff --git a/window-copy.c b/window-copy.c index bc3713b0..2ca5d961 100644 --- a/window-copy.c +++ b/window-copy.c @@ -795,16 +795,24 @@ window_copy_formats(struct window_mode_entry *wme, struct format_tree *ft) format_add(ft, "copy_cursor_x", "%d", data->cx); format_add(ft, "copy_cursor_y", "%d", data->cy); - format_add(ft, "selection_present", "%d", data->screen.sel != NULL); if (data->screen.sel != NULL) { format_add(ft, "selection_start_x", "%d", data->selx); format_add(ft, "selection_start_y", "%d", data->sely); format_add(ft, "selection_end_x", "%d", data->endselx); format_add(ft, "selection_end_y", "%d", data->endsely); - format_add(ft, "selection_active", "%d", - data->cursordrag != CURSORDRAG_NONE); - } else - format_add(ft, "selection_active", "%d", 0); + + if (data->cursordrag != CURSORDRAG_NONE) + format_add(ft, "selection_active", "1"); + else + format_add(ft, "selection_active", "0"); + if (data->endselx != data->selx && data->endsely != data->sely) + format_add(ft, "selection_present", "1"); + else + format_add(ft, "selection_present", "0"); + } else { + format_add(ft, "selection_active", "0"); + format_add(ft, "selection_present", "0"); + } format_add(ft, "search_present", "%d", data->searchmark != NULL); format_add_cb(ft, "search_match", window_copy_search_match_cb); -- 2.11.4.GIT