Show the window around the current position in GetChangeVisualizations - #98
Merged
Merged
Conversation
…ations [patch] GetChangeVisualizations(maxItems) returned the oldest maxItems commands, so with a long history it left out the current command and every recent or redoable change a history panel needs. Return the most recent commands instead, centring the window on the current position when it has been undone to before them, keep Position as the absolute stack index, return nothing for a non-positive limit, and return a snapshot rather than a lazy query over the live stack. Fixes #96 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N4m2HJkrsY88XBtTqTKAkE
|
matt-edmondson
deleted the
claude/undoredo-96-visualize-current-window
branch
September 27, 2026 00:18
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 #96
What changed
GetChangeVisualizations(maxItems)used to returncommands.Take(maxItems), which is the oldest commands. With 60 commands and the default limit of 50, a history panel never showed the current commandc59or the 9 commands before it.It now picks which commands to return like this:
maxItemscommands.Positionis still the absolute stack index, soIsExecutedandHasSaveBoundarystay correct for the shifted window. AmaxItemsof zero or less returns no items.The result is now a list rather than a lazy query over the live stack. This fixes the
GetChangeVisualizationshalf of #95. TheGetCommandsToUndohalf of #95 is left for its own PR.The XML doc on
IUndoRedoService.GetChangeVisualizationsanddocs/api-reference.mdnow describe which window is returned.Tests
New tests in
UndoRedoStackTests:c10..c59, ending atPosition == 59.The first four failed on
main. The full suite passes with the change (75/75).🤖 Generated with Claude Code
https://claude.ai/code/session_01N4m2HJkrsY88XBtTqTKAkE
Generated by Claude Code