Repository navigation
Keep a command a composite in the history holds out of CommandsDiscarded [patch] - #181
Open
matt-edmondson wants to merge 1 commit into
Open
matt-edmondson wants to merge 1 commit into
matt-edmondson wants to merge 1 commit into
Conversation
…ded [patch] OnCommandsDiscarded counted only the top-level commands as still in the history, so a command held by a composite in the history was reported when its own slot left. Grouping undone edits into a CompositeCommand reported them as Branched, and the README's dispose handler disposed commands the composite still runs. Replaced and Trimmed had the same gap. The history now counts every command reachable from it, walking nested composites, for every discard reason. Fixes #180 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW3sakBdbLSZUGjwGAi
|
This was referenced Nov 6, 2026
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 #180
What was wrong
OnCommandsDiscardedseeded its "still in the history" set from_stackManager.Commands, which holds only the top-level commands. A command held inside aCompositeCommandin the history didn't count, so it was reported when its own slot left. Only the Merged path had protection, through theCanReachfilter inExecuteMerged. The issue's repro (executeaandb, undo both, then executeCompositeCommand("group", [a, b])) reportedaandbas Branched. The README's handler then disposed them, andgroup's next Undo or Redo ran disposed commands. Replaced and Trimmed had the same gap.Change
ReachableFromHistory()walks the history's top-level commands and, recursively, the sub-commands of every composite among them. It keeps a visited set, so it walks a shared composite only once.OnCommandsDiscardedseedsunavailablefrom that walk, so Branched, Trimmed, Replaced and Cleared all get the same protection.CanReachfilter inExecuteMergedis now redundant but harmless. I left it in place so this PR doesn't conflict with Ask CanMergeWith once, and drop a merged-into command a failed merge leaves unapplied [minor] #176, which reworks that method.Tests
New
CompositeDiscardTestswith one test per acceptance criterion, plus one guard:GroupingUndoneEdits_DoesNotReportThemAsBranched: the issue's repro reports nothing.GroupingUndoneEdits_StillReportsTheEditsLeftOut: grouping onlya, inside a nested composite, still reportsbas Branched and keepsa.RestoringAStateWhoseCompositeHoldsACurrentCommand_DoesNotReportItAsReplaced: restoring[gx]overx.DroppingTheOldestCommand_…andTrimmingToMaxStackSize_…: a Trimmedxthat a remaining composite holds isn't reported.With the service change reverted, all 5 new tests fail. With it, the full suite passes: 211/211 on Linux / .NET 10.
Generated by Claude Code