Skip to content

Fix status bar duplication after vertical resize#1860

Merged
gnodet merged 1 commit into
jline:masterfrom
Abdelilah-AIT-HAMOU:fix-statusbar-vertical-resize
May 4, 2026
Merged

Fix status bar duplication after vertical resize#1860
gnodet merged 1 commit into
jline:masterfrom
Abdelilah-AIT-HAMOU:fix-statusbar-vertical-resize

Conversation

@Abdelilah-AIT-HAMOU
Copy link
Copy Markdown
Contributor

@Abdelilah-AIT-HAMOU Abdelilah-AIT-HAMOU commented May 1, 2026

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


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Bug Fixes**
  * Improved terminal resize handling when decreasing terminal height with active status output, ensuring proper cleanup of leftover status content.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

📝 Walkthrough

Walkthrough

The Status.resize method now includes additional cleanup logic to handle terminal height decreases. When rows are reduced, the clearStart position is moved upward by a computed status band offset, ensuring proper cleanup of leftover status output before clearing end-of-line contents.

Changes

Cohort / File(s) Summary
Status Resize Cleanup
terminal/src/main/java/org/jline/utils/Status.java
Added logic to adjust clearStart upward when terminal height decreases (newRows < oldRows), computing an offset based on scroll region and effective status lines to properly clean up leftover status output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 When terminals shrink and rows disappear,
Our Status now clears with purpose so clear,
Adjusting each band as heights take a fall,
No leftover clutter shall linger at all!
A tidy display, from top down to ground,
In seven neat lines, a fix so profound.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing status bar duplication that occurs after vertical resize, which is the core issue addressed in the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 1, 2026

@Abdelilah-AIT-HAMOU
Copy link
Copy Markdown
Contributor Author

Hello @gnodet , can you please take a look at this and let me know what you think !
the last few releases fixed many issues with resizing , this is the only still remaining one i could find !

@gnodet gnodet merged commit 5ef0aab into jline:master May 4, 2026
2 checks passed
gnodet added a commit that referenced this pull request May 4, 2026
Co-authored-by: Abdelilah AIT HAMOU <abdelilah.ait.hamou@oracle.com>
gnodet added a commit that referenced this pull request May 4, 2026
Co-authored-by: Abdelilah AIT HAMOU <abdelilah.ait.hamou@oracle.com>
@gnodet gnodet added the fix Bug fix label May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants