From e5a3be3c46418bb150a991bd70a8a38565849b2b Mon Sep 17 00:00:00 2001 From: otomist Date: Wed, 15 Jan 2025 12:04:34 -0500 Subject: [PATCH] use whitespace instead of new flag for selecting full line --- src/Surface.zig | 16 +++++++--------- src/terminal/Screen.zig | 6 ------ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index a8fd4a817..138aa2ea2 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -3563,17 +3563,15 @@ fn dragLeftClickTriple( const screen = &self.io.terminal.screen; const click_pin = self.mouse.left_click_pin.?.*; - // Get the line selection under our current drag point. If there isn't a line, do nothing. + // Get the line selection under our current drag point. If there isn't a + // line, do nothing. const line = screen.selectLine(.{ .pin = drag_pin }) orelse return; - // get the selection under our click point. - var sel_ = screen.selectLine(.{ .pin = click_pin }); - - // We may not have a selection if we started our triple-click in an area - // that had no data, in this case recall selectLine with allow_empty_lines. - if (sel_ == null) { - sel_ = screen.selectLine(.{ .pin = click_pin, .allow_empty_lines = true }); - } + // Get the selection under our click point. We first try to trim + // whitespace if we've selected a word. But if no word exists then + // we select the blank line. + const sel_ = screen.selectLine(.{ .pin = click_pin }) orelse + screen.selectLine(.{ .pin = click_pin, .whitespace = null }); var sel = sel_ orelse return; if (drag_pin.before(click_pin)) { diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index db890ad3f..eb70d32d0 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -2215,7 +2215,6 @@ pub const SelectLine = struct { /// state changing a boundary. State changing is ANY state /// change. semantic_prompt_boundary: bool = true, - allow_empty_lines: bool = false, }; /// Select the line under the given point. This will select across soft-wrapped @@ -2293,11 +2292,6 @@ pub fn selectLine(self: *const Screen, opts: SelectLine) ?Selection { return null; }; - // If we allow empty lines, we don't need to do any further checks. - if (opts.allow_empty_lines) { - return Selection.init(start_pin, end_pin, false); - } - // Go forward from the start to find the first non-whitespace character. const start: Pin = start: { const whitespace = opts.whitespace orelse break :start start_pin;