Skip to content

[BUG]: Every window resize leaves another prompt behind in foot #1068

Open

Description

@lenitain

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.

flyline-resize-bug flyline-resize-fixed

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

  1. Start foot with bash + flyline (no multiplexer).
  2. Resize the window several times. Dragging the edge works; with niri I alternate mod+f (niri msg action set-column-width "100%") and mod+a (set-column-width "25%").
  3. 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

  1. added
    bug
    on Nov 16, 2026
  2. HalFrgrd commented on Nov 16, 2026

    @HalFrgrd
    Owner

    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.

  3. added a commit that references this issue on Nov 17, 2026
    9e13d59
  4. lenitain commented on Nov 17, 2026

    @lenitain
    ContributorAuthor

    Thanks. I tried every --set-resize-logic value and the stacking remains. The flag only changes rows_up; before this PR the handler always sends DeleteLine(rows_up + 1) (v1.11.0, src/app/mod.rs:1060-1067).

    The prompt is four characters, so rows_up is 1 under every strategy. This isn't a reflow mismatch. In foot, DL is a scroll (term_scroll_partial, terminal.c:3095) that advances grid->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; resize moves CPR from 2;3 to 4;3, and without DL 2 it stays at 2;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:

    • Alacritty's DL also scrolls the region (rows can go into history), but reflow tracks an explicit cursor line and keeps the viewport pinned to the bottom, so the cursor stays aligned with the prompt and the old rows are not pulled back into view.
    • Kitty and Ghostty move/clear the deleted rows (no ring offset, no scrollback copy), and both honor the OSC 133 prompt-redraw markers: on resize they clear the prompt rows and let the shell redraw.

    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 get CUU + 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions