Repository navigation
Description
Describe the Bug
Every terminal resize leaves the previous prompt on screen and draws a new one below it, so a few resizes in a row fill the screen with stacked prompts. Nothing cleans them up; they stay in the scrollback.
Reproduced with a 4-character prompt (/tmp), so this is not about a long prompt wrapping. enable -d flyline (readline) does not have the problem, which points at the resize redraw path.
Environment & Version Information
flyline 1.10.0
git hash: ca91096
build mode: release
build datetime: 2026-10-17T14:03:33Z
build target: x86_64-unknown-linux-gnu
rustc version: rustc 1.99.1 (58cf8f9c3 2026-10-13)
Running in: Bash 5.3.20(1)-release
shell: /bin/bash
Running in: foot (Foot)
multiplexer: none
device attributes raw: >1;012800;0
device attributes version: 12800
program: unknown
program version: unknown
locale: zh_CN.UTF-8 (LC_ALL: unknown, LC_CTYPE: en_US.UTF-8)
Running in: CachyOS (kernel 7.3.4-1-cachyos x86_64)
system linker: GNU ld (GNU Binutils) 2.47
dynamic linker: ldd (GNU libc) 2.44
Running on: AMD Ryzen 5 4600U with Radeon Graphics (12 cores)
Running in: a simulation
Debug Logs (Optional / If Necessary)
Captured stream and analysis
Resize output captured with a PTY relay (the prompt block is 2 rows):
ESC[1A ESC[G ESC[2M ESC[G ESC[0J # Cursor::Up(rows_up), CHA 0, DeleteLine(rows_up+1), ED
ESC[6n # cursor position report
-> ESC[3;1R # cursor is on row 3, but the block starts on row 1
\n\n ESC[2A ... redraw
A minimal probe without flyline reproduces the shift: draw the two-row block (autowrap off, padded to the full width), send ESC[1A ESC[G ESC[2M, redraw, then resize. The CPR reply goes from 2;3 before the resize to 4;3 after it. Without the ESC[2M the reply stays 2;3.
foot debug build log for the same resize:
XSCROLL rows=2 region=0..29 offset=0->2 cursor=(0,0) # DeleteLine 2 advances the grid offset
XREFLOW enter ... cursor=(1,2) offset=2 # next reflow: screen row 1 + offset 2
XREFLOW after offset=0 cursor_screen=(3,2) # offset re-anchored, cursor lands 2 rows low
What happens
The TerminaEvent::WindowResized arm in src/app/mod.rs erases the inline viewport with Cursor::Up(rows_up), Edit::DeleteLine(rows_up + 1) and terminal.clear(), then redraws. rows_up comes from compute_wrapped_rows_up(), i.e. from the rows flyline itself drew, and assumes the terminal's screen still matches that model.
foot implements DL as a scroll of the cursor-to-bottom region (csi.c, case 'M' -> term_scroll_partial()), which does grid->offset += rows (terminal.c). The visible screen does not change, but the grid ring buffer is rotated. On the next reflow (grid_resize_and_reflow(), grid.c) foot turns the cursor into an absolute row (cursor.row += grid->offset), reflows, then re-anchors the grid (grid->offset = new_row_idx - new_screen_rows + 1, skipping empty rows). The cursor's screen row becomes old_screen_row + old_offset, i.e. it ends up offset rows below the prompt it belongs to.
flyline then moves up by rows_up from that shifted cursor, so the erase targets the rows below the old prompt. The old block survives, a new one is drawn below it, and the next resize repeats it.
Steps to Reproduce
- Start
footwith bash + flyline (no multiplexer). - Resize the window several times. Dragging the edge works; with niri I alternate
mod+f(niri msg action set-column-width "100%") andmod+a(set-column-width "25%"). - Every resize leaves another prompt block behind and draws a fresh one below it.
Expected: the prompt is redrawn in place, no matter how often the window is resized.
Actual: 3 narrow/wide cycles leave 6 extra prompt blocks (/tmp at rows 1, 3, 5, 7, 9, 11, 13, cursor on 13). See the "before" screenshot attached.
Activity
HalFrgrd commentedon Nov 16, 2026
Terminals and terminal emulators implement one of a few line reflow strategies when resizing.
flyline has a hidden cli flag to change which one it uses
flyline --set-resize-logic.I recommend trying each one and either making a PR to detect foot (there is some similar logic for zellij already) or keeping it set in your bashrc.
Stop stacking prompts when the terminal is resized
lenitain commentedon Nov 17, 2026
Thanks. I tried every
--set-resize-logicvalue and the stacking remains. The flag only changesrows_up; before this PR the handler always sendsDeleteLine(rows_up + 1)(v1.11.0,src/app/mod.rs:1060-1067).The prompt is four characters, so
rows_upis 1 under every strategy. This isn't a reflow mismatch. In foot, DL is a scroll (term_scroll_partial,terminal.c:3095) that advancesgrid->offset. The next reflow adds that offset to the cursor before re-anchoring the grid (grid.c:855,grid.c:1216), so the cursor ends up below the prompt. The probe shows the same thing.CUU 1; CHA 0; DL 2; redraw; resizemoves CPR from2;3to4;3, and withoutDL 2it stays at2;3. I'm not saying foot's visible DL behavior is wrong; Flyline just shouldn't use DL as an erase and then trust its own cursor model.Alacritty Kitty and Ghostty don't fail because they don't satisfy the full condition, not because they need a different fix:
The failure requires all three ingredients foot has: DL advances a global
grid->offset, reflow uses that offset to convert the cursor, and the "deleted" rows remain in the ring and can be reflowed back. They are not handling DL "better"; they simply never enter the state where a hidden offset is applied to the cursor during reflow. The PR does not detect foot; it removes DL from the direct-terminal path, so any terminal with that combination is covered, while the multiplexer path keeps the zellij workaround.The fix only gates DL on
multiplexer().is_some(). DL stays for zellij/tmux/screen; direct terminals getCUU+ED(0), which already clears the block. Everything else is untouched, and multiplexer behavior is unchanged.The regression test runs in CI through
docker/bash_integration_test.Dockerfile. It waits for the CPR query after each resize, so it fails if the resize path isn't exercised. All checks pass, including Code Quality, the Ubuntu build, and all five Bash versions. I also tested foot, zellij, Alacritty, Kitty, and Ghostty manually and saw no regressions.