Repository navigation
X11: Bash cursor moves inside a soft-wrapped prompt after resize with shell integration disabled #14026
Issue DescriptionOn Ghostty 1.3.1 using the GTK X11 backend, shrinking a window until the current Bash prompt soft-wraps and then widening it again can leave the cursor inside the prompt instead of after it. The same test does not reproduce for me with Ghostty's native Wayland backend. This reproducer explicitly disables Ghostty shell integration. Related reports such as #1961, #209, and #2214 are not exact duplicates, but they are useful context: they are why I made sure this case can be reproduced without shell integration or a multiline/dynamic prompt. Expected BehaviorAfter the window is widened again, the prompt should appear once and the cursor should remain immediately after the trailing space. Actual BehaviorAfter the narrow-to-wide resize, the cursor lands partway through the prompt. Repeating the resize can leave additional corrupted or duplicated prompt fragments. Reproduction Steps
For an even more isolated Bash environment, Running the equivalent command without Ghostty LogsI did not observe a relevant warning or error in the log. The failure is visible as incorrect terminal state after the resize rather than as a crash. Ghostty VersionOS Version Information(Linux only) Display ServerThe desktop session is Wayland. The failing Ghostty instance is explicitly run with (Linux only) Desktop Environment/Window ManagerGNOME Shell 50.4 Minimal Ghostty ConfigurationNo configuration is required. Shell integration is disabled on the command line: Additional Relevant ConfigurationTentative explanation, not a confirmed diagnosis: Ghostty's terminal I/O thread coalesces resize notifications, while GTK's X11 and Wayland backends can deliver different allocation/configure sequences. On X11, an intermediate narrow size may be committed to the terminal and PTY: Ghostty reflows the existing prompt, Bash receives AI Assistance DisclosureThis report was prepared with assistance from OpenAI Codex. I developed and manually verified the reproducer and the X11/Wayland behavior. Codex helped inspect Ghostty's resize path, locate related reports, formulate the tentative explanation, and edit the report. I reviewed the related reports and edited the final framing to explain why the shell-integration-free reproducer matters before submission. Acknowledgements
|
Replies: 1 comment 1 reply
|
I'd bet this isn't really a backend difference, and that X11 just hands you more chances to hit it. Bash redraws on SIGWINCH through readline, and readline tracks the cursor itself rather than asking the terminal where it is. Ghostty rewraps soft-wrapped text on resize by default, Shell integration papers over this precisely because it hands ghostty prompt marks, so the terminal knows where the prompt begins and can put things back. You turned it off deliberately, which is the right instinct for isolating a bug, but it also removes the only channel either side has for agreeing on where the prompt is. X11 vs Wayland then falls out of how many SIGWINCHs land during the drag rather than anything about what got committed to the pty. GTK's X11 backend fires configure events continuously while you're dragging, Wayland typically gives you far fewer intermediate sizes. More redraws at more widths, more chances for readline to be holding the wrong number when you let go. There's a cheap way to decide this before anyone goes digging through the resize path. Run the identical reproducer under zsh: PS1="someitnh rellayl logn so you can see" GDK_BACKEND=x11 ghostty --shell-integration=none -e zsh -fzle redraws on SIGWINCH quite differently from readline. If zsh stays clean through the same drag, the reflow contract is fine and this is readline's bookkeeping, which would make it a wontfix here and a known bash quirk everywhere. If zsh corrupts too, then your intermediate-size theory is worth chasing and it's genuinely a ghostty bug. Two minutes either way and it tells you which half to look at. |
I'd bet this isn't really a backend difference, and that X11 just hands you more chances to hit it.
Bash redraws on SIGWINCH through readline, and readline tracks the cursor itself rather than asking the terminal where it is. Ghostty rewraps soft-wrapped text on resize by default,
Screen.ResizeOptionshasreflow: bool = true, and it does fix up its own cursor through the reflow. So after the narrow-to-wide drag the terminal's cursor is where it should be, but readline still believes the prompt is sitting on the second row of a wrapped line, and its redraw moves the real cursor back to match that stale belief. That's your cursor landing partway through the prompt, and the duplicated fragme…