Skip to content

fix(renderer): don't trim final newline (because it can be intentional) - #1798

Open
meowgorithm wants to merge 2 commits into
mainfrom
fix/preserve-trailing-blank-lines
Open

meowgorithm wants to merge 2 commits into
mainfrom
fix/preserve-trailing-blank-lines

Conversation

@meowgorithm

Copy link
Copy Markdown
Member

This revision maintains trailing newlines, because trailing blank lines can be a design choice. Prior to this change it was nearly impossible to keep them.

Worth testing this one thoroughly, per the removed comment in the code.

@codecov

codecov Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.58%. Comparing base (d5bfd5c) to head (5617f4d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1798      +/-   ##
==========================================
+ Coverage   59.35%   63.58%   +4.23%     
==========================================
  Files          25       25              
  Lines        1341     1538     +197     
==========================================
+ Hits          796      978     +182     
- Misses        456      464       +8     
- Partials       89       96       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@andrinoff andrinoff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also a pre-existing bug that a view without a trailing newline loses its last line on exit. close moves to the last buffer row and erases below it, so the shell prompt overwrites that line. Maybe worth fixing here too

Comment thread cursed_renderer.go Outdated
// than on its last visible line. Frames taller than the screen
// have their top rows dropped, so their last visible row is the
// screen's.
y := frameArea.Dy() - 1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parking at the frame's last row is correct, but for frames taller than the screen this now aligns the frame with the top of the terminal, and the existing per-frame full redraw then floods scrollback in tmux

Comment thread cursed_renderer_test.go

// Frames taller than the screen drop their top rows, so the parked cursor
// must land on the screen's last visible row, not beyond it.
func TestCursedRenderer_trailingBlankLinesTallFrame(t *testing.T) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this checks the parked position but not that a second unchanged flush is a no-op. that's why the regression above was missed

@andrinoff
andrinoff force-pushed the fix/preserve-trailing-blank-lines branch from 3dd74a3 to 5617f4d Compare September 28, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants