fix: don't use with_selection_const in primary_drag

with_selection_const destroys the selection on movement errors.

closes #406
This commit is contained in:
CJ van den Berg 2025-12-28 21:20:58 +01:00
parent 1685b3204c
commit 1be41aff8b
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -2662,21 +2662,21 @@ pub const Editor = struct {
.word => { .word => {
if (sel.is_reversed()) { if (sel.is_reversed()) {
sel.begin = initial.end; sel.begin = initial.end;
with_selection_const(root, move_cursor_word_begin, primary, self.metrics) catch {}; move_cursor_word_begin(root, &sel.end, self.metrics) catch {};
} else { } else {
sel.begin = initial.begin; sel.begin = initial.begin;
with_selection_const(root, move_cursor_word_end, primary, self.metrics) catch {}; move_cursor_word_end(root, &sel.end, self.metrics) catch {};
} }
}, },
.line => { .line => {
if (sel.is_reversed()) { if (sel.is_reversed()) {
sel.begin = initial.end; sel.begin = initial.end;
with_selection_const(root, move_cursor_begin, primary, self.metrics) catch {}; move_cursor_begin(root, &sel.end, self.metrics) catch {};
} else { } else {
sel.begin = initial.begin; sel.begin = initial.begin;
blk: { blk: {
with_selection_const(root, move_cursor_end, primary, self.metrics) catch break :blk; move_cursor_end(root, &sel.end, self.metrics) catch break :blk;
with_selection_const(root, move_cursor_right, primary, self.metrics) catch {}; move_cursor_right(root, &sel.end, self.metrics) catch {};
} }
} }
}, },