From 5e2ac205fd5dab8f2bb306ed66d12237ff51c3f7 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 24 Jul 2019 19:00:52 +0100 Subject: [PATCH] term_clrsb(): call deselect() if the selection was affected. Any terminal event that modifies the range of screen+scrollback currently covered by the mouse selection should call deselect(), so that users won't be misled into thinking that the new version of the highlighted text would be pasted, and also so that using the MBT_EXTEND action to modify the selection bounds won't start from a selection you never had in the first place. Clearing the scrollback is such an event, if the selection covered any of the scrollback at all; so we should apply the same policy here as everywhere else. --- terminal.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/terminal.c b/terminal.c index c1a12c04..528f8f9b 100644 --- a/terminal.c +++ b/terminal.c @@ -1633,6 +1633,13 @@ void term_clrsb(Terminal *term) for (i = 0; i < term->rows; i++) check_line_size(term, scrlineptr(i)); + /* + * That operation has invalidated the selection, if it overlapped + * the scrollback at all. + */ + if (term->selstate != NO_SELECTION && term->selstart.y < 0) + deselect(term); + /* * There are now no lines of real scrollback which can be pulled * back into the screen by a resize, and no lines of the alternate