Repository navigation
Keep list siblings when undoing a move, and keep the node a drop displaces - #189
Merged
Merged
Conversation
… displaces [patch] Undo put a node back with MoveTo, which replaces the entry at the old index. Taking the node out had already shifted its next sibling into that index, so undoing a remove or disconnect in a body, parameter or member list deleted the next sibling. Connecting within a list replaced the wrong entry for the same reason, and the entry a drop replaced left the graph with no trace. - AstSchema.TryInsertAt inserts into a sequence instead of replacing. - AstGraph.PutBack is MoveTo's inverse and inserts; undo uses it. - MoveTo adjusts the index for a move later within the same sequence, and leaves the entry it replaces as a loose node. - The editor's recorded move puts that displaced node back on undo. Fixes #91 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXWSrf4nXKEZF5xVNTiVV5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AXWSrf4nXKEZF5xVNTiVV5
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #91
Problem
Undo put a node back with
AstGraph.MoveTo. When the slot is a sequence,MoveToreplaces the entry at the old index rather than inserting there. Taking the node out had already shifted its next sibling into that index, so undoing a Remove or a Disconnect of a middle statement deleted the statement after it. Connecting a node to a later pin in its own list replaced the wrong entry for the same reason. And the entry a drop replaced left the graph with no trace, so it couldn't be recovered even by undo.Change
AstSchema.TryInsertAtinserts into a sequence and shifts later entries up. It is built from the existing append and detach operations, so it doesn't add another per-slot switch.AstGraph.PutBackis the inverse ofMoveTo: same location, insert semantics. Every undo of a remove or a move now uses it.AstGraph.MoveTokeeps its replace-on-a-filled-pin behaviour, with two fixes:Replacealready treats children it can't move.AstGraphEditor.RecordMoverecords the displaced occupant. On undo it puts back both the node and the occupant, in ascending order of where each came from, so both indices refer to their original positions again.For the design question in the triage: I kept the existing default, where a drop onto a filled pin replaces the occupant. The occupant now goes into
detachedand comes back on undo.Tests
AstGraphSequenceUndoTestscovers the issue's acceptance criteria on a[s0, s1, s2]body:Body[0]ontoBody[1]:s1is replaced and stays loose. Undo restores the body exactly, and redo matches the first result.Body[0]: the occupant stays loose. Undo restores the body and leaves the node loose.TryInsertAtshifts later entries up.With the
AstGraphandAstGraphEditorchanges reverted, the four undo tests fail. Full suite: 1093 passed, 0 failed. The solution builds with 0 warnings.🤖 Generated with Claude Code
https://claude.ai/code/session_01AXWSrf4nXKEZF5xVNTiVV5
Generated by Claude Code