Fix status bar duplication after vertical resize by Abdelilah-AIT-HAMOU · Pull Request #1860 · jline/jline3 (original) (raw)

Summary

Fix stale status bar rows after vertical terminal resize.

When the terminal height shrinks, some terminal emulators keep the old bottom status line just above the new status area. JLine then redraws the status bar at the new bottom row, which leaves duplicated status bar rows in the main terminal area.

This change clears one status-height band above the new status area during Status.resize(...) when the terminal height shrinks.

before :
image

after :
image

Reproduction

A small app using Status with LineReader.readLine() can reproduce the issue:

Terminal terminal = TerminalBuilder.builder() .name("jline-status-resize-repro") .system(true) .dumb(false) .exec(true) .build();

Status status = Status.getStatus(terminal, true);

LineReader reader = LineReaderBuilder.builder() .terminal(terminal) .appName("jline-status-resize-repro") .build();

reader.getWidgets().put(LineReader.CALLBACK_INIT, () -> { status.update( Collections.singletonList(new AttributedString("viins | 1:0 | NOLOG | NOLOG")), true); return true; });

while (true) { String line = reader.readLine("SQL> "); if (line == null || "exit".equalsIgnoreCase(line.trim())) { break; } reader.printAbove("accepted: " + line); }

Steps:

Run the reproducer in macOS Terminal. Wait at the SQL> prompt with the status bar visible. Resize the terminal vertically smaller/larger. Before this fix, duplicate status bar rows can remain above the prompt. After this fix, the stale status row is cleared and only the bottom status bar remains.

Fix Status.resize(Size) already clears old status remnants when the width decreases or the terminal height grows.

This patch adds the missing shrink case:

detect when the new terminal row count is smaller than the old row count move clearStart up by one status-height band above the new status area clear those rows before reapplying the scroll region Validation Manually verified with the standalone reproducer:

vertical resize smaller/larger no longer leaves duplicated status bar rows horizontal resize behavior remains unchanged prompt remains usable after resize

Summary by CodeRabbit