fix extend direction in Selection

This commit is contained in:
Muki Kiboigo
2026-01-15 23:22:17 -08:00
parent fa3a23134e
commit 12670a3153
2 changed files with 7 additions and 2 deletions

View File

@@ -270,7 +270,7 @@
testing.expectEqual(true, sel.isCollapsed); testing.expectEqual(true, sel.isCollapsed);
testing.expectEqual(10, sel.anchorOffset); testing.expectEqual(10, sel.anchorOffset);
testing.expectEqual(10, sel.focusOffset); testing.expectEqual(10, sel.focusOffset);
testing.expectEqual("forward", sel.direction); testing.expectEqual("none", sel.direction);
} }
</script> </script>

View File

@@ -208,11 +208,16 @@ pub fn extend(self: *Selection, node: *Node, _offset: ?u32) !void {
try range.setEnd(old_anchor, old_anchor_offset); try range.setEnd(old_anchor, old_anchor_offset);
self._direction = .backward; self._direction = .backward;
}, },
else => { .after => {
try range.setStart(old_anchor, old_anchor_offset); try range.setStart(old_anchor, old_anchor_offset);
try range.setEnd(node, offset); try range.setEnd(node, offset);
self._direction = .forward; self._direction = .forward;
}, },
.equal => {
try range.setStart(old_anchor, old_anchor_offset);
try range.setEnd(old_anchor, old_anchor_offset);
self._direction = .none;
},
} }
} }