Fix Windows crash when switching to fullscreen mode with a custom pager#5838
Open
stefanhaller wants to merge 5 commits into
Open
Fix Windows crash when switching to fullscreen mode with a custom pager#5838stefanhaller wants to merge 5 commits into
stefanhaller wants to merge 5 commits into
Conversation
The fallback path in newPtyTask (taken when StartPty fails) needs the same start-the-command-with-a-pipe logic that newCmdTask uses, so pull it out into a helper that both can share. No behavior change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
NewCmdTask feeds the reader returned by its start func straight into a bufio.Scanner, whose Scan panics on a nil reader with a nil pointer dereference. startCmdWithPipe returns exactly that when the pipe cannot be created. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
NewCmdTask feeds the reader returned by its start func into a bufio.Scanner, and Scanner.Scan panics with a nil pointer dereference when that reader is nil. Two start funcs could produce one: - newPtyTask's fallback for a failed StartPty returned a literal nil reader, alongside an ExecCmd that was never started, so the intended "fall back to a plain cmd task" never worked. This crashed lazygit on Windows when using a custom pager with the main view zero-sized, e.g. after pressing + twice to enter full-screen mode with a side panel focused: ConPTY rejects zero dimensions, making StartPty fail. - startCmdWithPipe returned nil when the pipe couldn't be created, which the Unix pty fallback path can trigger, since a failed pty start can leave the tty assigned to the command's stdout. Make startCmdWithPipe never return a nil reader: when the pipe can't be created, don't start the command at all and return an empty reader so the task shuts down cleanly with the error in the log. Then route newPtyTask's fallback through it, so a StartPty failure degrades to running the command without a pty: the pager is lost, but the command's output still renders. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
CreatePseudoConsole rejects zero dimensions with E_INVALIDARG, so starting a pty sized after a hidden (and thus zero-sized) view fails. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
CreatePseudoConsole and ResizePseudoConsole reject zero dimensions with E_INVALIDARG, but we legitimately request them: the pty is sized after the main view, and that view is zero-sized while hidden, e.g. in full-screen mode with a side panel focused. Entering that mode while a custom pager is configured therefore made StartPty fail (degrading to unpaged output now that the fallback works), and resizing a live pty from onResize would fail layout. The Unix pty accepts zero sizes, so the clamp lives in the Windows implementation only. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Fix a crash when typing
+twice to go to full screen mode, when a custom pager such as delta or difftastic is configured.Fixes #5837.