From b38927364ca749674397c36527e334d066a5ff02 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 11 Jan 2024 14:37:18 -0700 Subject: [PATCH] Clear terminal selection on escape --- src/terminal_box.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/terminal_box.rs b/src/terminal_box.rs index e485925..443ece8 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -584,7 +584,15 @@ where status = Status::Captured; } KeyCode::Escape => { - terminal.input_scroll(b"\x1B".as_slice()); + let had_selection = { + let mut term = terminal.term.lock(); + term.selection.take().is_some() + }; + if had_selection { + terminal.update(); + } else { + terminal.input_scroll(b"\x1B".as_slice()); + } status = Status::Captured; } KeyCode::Up => {