Skip to content

Entity-aware select/move tool and smarter snapping - #368

Merged
lewish merged 1 commit into
mainfrom
entity-aware-select-and-snapping
Jul 9, 2026
Merged

lewish merged 1 commit into
mainfrom
entity-aware-select-and-snapping

Conversation

@lewish

@lewish lewish commented Jun 26, 2026

Copy link
Copy Markdown
Owner

What

Reworks the select tool to be entity-aware and makes snapping rebuild connections cleanly when shapes move or are drawn.

Select tool

  • Move a whole box — grab a box's empty interior and drag. Border + contents move, and attached lines stay connected and reflow: straight runs shorten/lengthen, perpendicular moves bend, the connector is traced through corners to its real terminal, and arrows pointing into the box ride along.
  • Resize a box edge — grab the border (unchanged DrawMove).
  • Reshape a line tip — drag a free tip and it behaves like the line tool (free 2D, corners), pivoting at the nearest bend; bend orientation follows the segment's own axis (Ctrl/Shift flips).
  • Move a word — grab a run of text. Shift-click to build a multi-selection.
  • Rubber-band selections reflow lines that cross the selection edge.
  • Selection travels with undo/redo and is purged when leaving the tool.

Snapping

  • Accumulate connections so a cell that gains/loses several at once lands on the right junction (no more last-write-wins leaving a side disconnected).
  • Complete the disconnect table for ┼ (DOWN/LEFT/RIGHT) so drawing a line onto another yields a T, not a +.
  • Normalisation pass — after a change, each affected line/junction is tidied to match its neighbours (a dangling ┤ → │, a stray ┼ → the right T, a moved box's connection points settle correctly). Scoped to never mutate the content being moved, only the structure around it.
  • Boxes snap to adjacent lines/boxes when drawn, like lines already did.

Testing

New specs cover the happy paths and every regression fixed here: entity.spec, select.spec, snap.spec, box.spec, line.spec, grid.spec (incl. a 2x2-grid quadrant move). All client + common suites pass.

🤖 Generated with Claude Code

Reworks the select tool to understand the things under the cursor, and
makes snapping rebuild connections cleanly when shapes move or are drawn.

Select tool (client/draw/select.ts, client/draw/entity.ts):
- Grab a box's interior to move the whole box and its contents; attached
  lines stay connected and reflow — straight runs shorten/lengthen,
  perpendicular moves bend, traced through corners to the real terminal,
  and arrows that point into the box ride along.
- Box borders/lines still resize via the existing DrawMove.
- Drag a free line tip to reshape it like the line tool (free 2D with
  corners), pivoting at the nearest bend; orientation follows the
  segment's own axis (Ctrl/Shift flips).
- Move a word (run of text); shift-click to build a multi-selection.
- Rubber-band selections reflow edge-crossing lines too.
- Selection travels with undo/redo and is purged when leaving the tool.

Snapping (client/snap.ts, client/characters.ts):
- Accumulate connections so a cell gaining/losing several at once lands
  on the right junction instead of the last one winning.
- Complete the disconnect table for ┼ (DOWN/LEFT/RIGHT) so drawing onto a
  line yields a T, not a +.
- Normalisation pass: after a change, tidy each affected line/junction to
  match its neighbours (a dangling ┤ → │, stray ┼ → the right T, etc.),
  scoped to never mutate the content being moved.
- Boxes now snap to adjacent lines/boxes when drawn, like lines do.

Tests: new entity/select/snap/box/line/grid specs cover the happy paths
and the regressions fixed here. All client + common suites pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lewish
lewish merged commit 81e075c into main Jul 9, 2026
1 check passed
@lewish
lewish deleted the entity-aware-select-and-snapping branch July 9, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant