Skip to content

Show the window around the current position in GetChangeVisualizations - #98

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/undoredo-96-visualize-current-window
Sep 27, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
claude/undoredo-96-visualize-current-window

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #96

What changed

GetChangeVisualizations(maxItems) used to return commands.Take(maxItems), which is the oldest commands. With 60 commands and the default limit of 50, a history panel never showed the current command c59 or the 9 commands before it.

It now picks which commands to return like this:

  • Default: the most recent maxItems commands.
  • Current position undone to before that window: the window is centred on the current position, so it holds the current command and the redoable commands after it.

Position is still the absolute stack index, so IsExecuted and HasSaveBoundary stay correct for the shifted window. A maxItems of zero or less returns no items.

The result is now a list rather than a lazy query over the live stack. This fixes the GetChangeVisualizations half of #95. The GetCommandsToUndo half of #95 is left for its own PR.

The XML doc on IUndoRedoService.GetChangeVisualizations and docs/api-reference.md now describe which window is returned.

Tests

New tests in UndoRedoStackTests:

  • 60 commands with a limit of 50 returns c10..c59, ending at Position == 59.
  • After 5 undos, the current command (54) is marked executed, and the 5 redoable commands are included and marked not executed.
  • After 40 undos with a limit of 10, the window contains position 19 and some redoable commands, and positions are absolute.
  • A save boundary inside a shifted window is reported at its absolute position.
  • A limit of zero or a negative limit returns an empty result. This passed before the change too; the test guards the explicit handling.

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

…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
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit c22dd5b into main Sep 27, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the claude/undoredo-96-visualize-current-window branch September 27, 2026 00:18
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.

GetChangeVisualizations(maxItems) returns the oldest commands, leaving out the current position and all recent or redoable history

2 participants