Conversation
checkResize() was a stub that always returned false on Windows, so Program.tick() never entered the resize branch — context.width/height stayed frozen at startup and no window_size message was ever dispatched. Detect resize by polling GetConsoleScreenBufferInfo and comparing the srWindow dimensions against the last observed size. WINDOW_BUFFER_SIZE_EVENT is not used because those records are only queued when ENABLE_WINDOW_INPUT is set, which enableRawMode deliberately avoids. A first-read guard establishes the baseline without reporting a spurious startup resize. checkResize now takes the same stdout handle getSize uses (state.stdout_handle) so detection and measurement agree when a custom Config.output handle is set.
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.
Problem
Fixes #114. On Windows,
checkResize()was a stub that always returnedfalse, soProgram.tick()never entered the resize branch —context.width/context.heightstayed frozen at startup values and thewindow_sizemessage was never dispatched. zigzag TUIs on Windows never adapted to a resized terminal window.Fix
Detect resize by polling
GetConsoleScreenBufferInfoand comparing thesrWindowdimensions against the last observed size.WINDOW_BUFFER_SIZE_EVENTis intentionally not used: per the Windows Console docs, those records are only queued whenENABLE_WINDOW_INPUTis set on the input mode, whichenableRawModedeliberately avoids (it wakes the stdin wait-handle without producingReadFilebytes). Polling is the only viable mechanism under the current input mode, and it works under the classic console host. Under ConPTY/Windows Terminal a transiently stale reading self-corrects because the size is re-polled every frame; it degrades gracefully (returnsfalse) when stdout isn't a console.Notes:
checkResizenow takes the same stdout handlegetSizeuses (state.stdout_handle), so detection and measurement agree when a customConfig.outputhandle is set.Verification
x86_64-windows-gnu), POSIX (native), and WASM.zig build testpasses.