From 32588a647f8153d13848cac49a55436ed5d4c725 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 30 Jun 2024 10:24:53 -0700 Subject: [PATCH] core: on right click, only create selection if point isn't in prev sel --- src/Surface.zig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Surface.zig b/src/Surface.zig index 5573f6ef6..9d670cf23 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -2433,6 +2433,15 @@ pub fn mouseButtonCallback( break :pin pin; }; + // If we already have a selection and the selection contains + // where we clicked then we don't want to modify the selection. + if (self.io.terminal.screen.selection) |prev_sel| { + if (prev_sel.contains(screen, pin)) break :sel; + + // The selection doesn't contain our pin, so we create a new + // word selection where we clicked. + } + const sel = screen.selectWord(pin) orelse break :sel; try self.setSelection(sel); try self.queueRender();