diff --git a/CHANGELOG.md b/CHANGELOG.md index 5792c240..609bc084 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,12 @@ ## Unreleased ### Added ### Changed + +* No longer copies empty text after selection ([#2327][2327]). + +[2327]: https://codeberg.org/dnkl/foot/issues/2327 + + ### Deprecated ### Removed ### Fixed diff --git a/selection.c b/selection.c index 0a479ee8..bb0d3f1b 100644 --- a/selection.c +++ b/selection.c @@ -1948,6 +1948,9 @@ static const struct zwp_primary_selection_source_v1_listener primary_selection_s bool text_to_clipboard(struct seat *seat, struct terminal *term, char *text, uint32_t serial) { + if (text == NULL || text[0] == '\0') + return false; + xassert(serial != 0); struct wl_clipboard *clipboard = &seat->clipboard; @@ -2418,6 +2421,9 @@ selection_from_clipboard(struct seat *seat, struct terminal *term, uint32_t seri bool text_to_primary(struct seat *seat, struct terminal *term, char *text, uint32_t serial) { + if (text == NULL || text[0] == '\0') + return false; + if (term->wl->primary_selection_device_manager == NULL) return false;