Shift Spectre cursor positions to 1-based and clip WriteAt to the screen - #146
Merged
Merged
Conversation
…e screen [patch] SetCursorPosition passed 0-based coordinates straight to Spectre, which emits them as a 1-based ANSI CUP sequence, so rows 0 and 1 (and columns 0 and 1) collapsed and the last row and column were unreachable. WriteAt also wrote text whose position was off-screen at wherever the cursor had been left, and let text overflow the right edge onto the next row. It now skips off-screen rows and clips text to the visible columns. Fixes #138 Fixes #139 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015cCJCbaqmqLWvEB1Pep4Q9
|
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 #138
Fixes #139
Both bugs are on the same
SetCursorPosition/WriteAtpath inSpectreConsoleProvider, so the triage on each recommended fixing them together.What changed
SetCursorPositionpassed 0-based coordinates straight to Spectre. Spectre writes them unchanged into the ANSI CUP sequence, which is 1-based, so rows 0 and 1 collapsed into one line (and so did columns 0 and 1), and the last row and column could never be drawn. It now adds 1 on both axes.SetCursorVisibilityre-set the cursor with the same 0-based coordinates, so it gets the same shift.WriteAtnow clips to the screen before it moves the cursor:[0, Height)writes nothing, where before the text went wherever the previous write had left the cursor[0, Width)writes nothingTests
SpectreConsoleProviderTestscaptures the provider's ANSI output from a 10×5 Spectre console over aStringWriter. It covers the (0,0)/(0,1)/(1,0)/(W-1,H-1) cursor sequences, off-screen rows, text wholly left or right of the screen, a negative start X, and right-edge overflow.SpectreConsoleProvider.csreverted: all 10 new test cases fail, and the 177 existing tests still pass.🤖 Generated with Claude Code
https://claude.ai/code/session_015cCJCbaqmqLWvEB1Pep4Q9
Generated by Claude Code