summaryrefslogtreecommitdiffstats
path: root/paste.c
diff options
context:
space:
mode:
authornicm <nicm>2022-06-04 07:42:07 +0000
committernicm <nicm>2022-06-04 07:42:07 +0000
commit020c403dff56269d93625970ed41761520afc853 (patch)
tree5bcf6a32a82e54eae546fb2898f04e5eec407c53 /paste.c
parent3edda3c5e71d634efd8e1e849328a68fb9da37de (diff)
When picking a buffer because one isn't specified by the user, ignore
named buffers. GitHub issue 3212 from David le Blanc.
Diffstat (limited to 'paste.c')
-rw-r--r--paste.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/paste.c b/paste.c
index 46f218d2..5ff36854 100644
--- a/paste.c
+++ b/paste.c
@@ -112,6 +112,12 @@ paste_walk(struct paste_buffer *pb)
return (RB_NEXT(paste_time_tree, &paste_by_time, pb));
}
+int
+paste_is_empty(void)
+{
+ return RB_ROOT(&paste_by_time) == NULL;
+}
+
/* Get the most recent automatic buffer. */
struct paste_buffer *
paste_get_top(const char **name)
@@ -119,6 +125,8 @@ paste_get_top(const char **name)
struct paste_buffer *pb;
pb = RB_MIN(paste_time_tree, &paste_by_time);
+ while (pb != NULL && !pb->automatic)
+ pb = RB_NEXT(paste_time_tree, &paste_by_time, pb);
if (pb == NULL)
return (NULL);
if (name != NULL)