diff options
| author | otomist <otomist@users.noreply.github.com> | 2025-01-14 12:04:43 -0500 |
|---|---|---|
| committer | otomist <otomist@users.noreply.github.com> | 2025-01-14 12:04:43 -0500 |
| commit | 95debc59d1b422e0c544a5b80286dfdadda5512b (patch) | |
| tree | 8cdaf78eba52e9e7a66044fea41a5c04c9f90766 /src/Surface.zig | |
| parent | d1fd22ae80f764aea5c05987871a58a2fb776862 (diff) | |
add and use flag for selecting empty lines in the selectLine function
Diffstat (limited to 'src/Surface.zig')
| -rw-r--r-- | src/Surface.zig | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/Surface.zig b/src/Surface.zig index 5a1d8c01d..a8fd4a817 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -3563,22 +3563,23 @@ fn dragLeftClickTriple( const screen = &self.io.terminal.screen; const click_pin = self.mouse.left_click_pin.?.*; - // Get the word under our current point. If there isn't a word, do nothing. - const word = screen.selectLine(.{ .pin = drag_pin }) orelse return; - - // Get our selection to grow it. If we don't have a selection, start it now. - // We may not have a selection if we started our dbl-click in an area - // that had no data, then we dragged our mouse into an area with data. - var sel = screen.selectLine(.{ .pin = click_pin }) orelse { - try self.setSelection(word); - return; - }; + // 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 }); + } - // Grow our selection + var sel = sel_ orelse return; if (drag_pin.before(click_pin)) { - sel.startPtr().* = word.start(); + sel.startPtr().* = line.start(); } else { - sel.endPtr().* = word.end(); + sel.endPtr().* = line.end(); } try self.setSelection(sel); } |
