Visitar URL original
Message pager drops blank separators when scrolling back by akasakariko · Pull Request #21444 · vim/vim · GitHub
Skip to content

Message pager drops blank separators when scrolling back - #21444

Open
akasakariko wants to merge 1 commit into
vim:masterfrom
akasakariko:fix/more-prompt-empty-lines
Open

akasakariko wants to merge 1 commit into
vim:masterfrom
akasakariko:fix/more-prompt-empty-lines

Conversation

@akasakariko

@akasakariko akasakariko commented Oct 4, 2026 •

Copy link
Copy Markdown

What does this change do?

When scrolling back through message output using b or PageUp, blank line separators are omitted. Preserve those empty lines in message scrollback.

Commit message

Problem:  Message pager drops blank separators when scrolling back.
Solution: Store standalone newline chunks during message display and
          avoid adding an extra blank line in msg_sb_eol() when a trailing
          newline exists (KayanoLiam).

fixes: #21315
closes: #21444

AI assistance

  • AI involvement is disclosed in the commit message, or no AI was used

OpenAI Codex assisted investigation, code/test changes, and validation. Antigravity Gemini 3.8 Flash drafted the PR title and description.

Checklist

  • The commit message follows the Problem/Solution form above
  • Signed-off-by: trailer is present (git commit -s), recommended but not required
  • Tests were added, existing tests cover the change, or the change cannot be tested (say why)
  • Documentation under runtime/doc/ was updated, or no update is needed

Anything reviewers should know

Visible Behavior:
Trailing empty lines are retained by G at the more-prompt and g< after Enter, matching the original screen display.

Reproduction and Test Coverage:

  • Test_message_scrollback_empty_lines: Original screendump test covers 1, 2, and 3 newline separators with f/b and PageDown/PageUp.
  • Test_message_scrollback_trailing_empty_lines: New test checks exact terminal line output for G at the more-prompt and subsequent g< after Enter across 0 through 3 trailing newlines (0 serves as a boundary control).
  • Test_echo_verbose_system: Covers the msg_sb_eol() guard against extra blank lines (not the separator loop).
  • Reproduction evidence: Restoring pre-PR src/message.c causes Test_message_scrollback_empty_lines and Test_message_scrollback_trailing_empty_lines to fail. Reverting only the msg_sb_eol() change causes Test_echo_verbose_system to fail while the separator loop continues to pass.

Validation Details:

  • Validated on macOS arm64 (Clang) and Ubuntu 24.04 arm64 (GCC) inside Docker via Colima, using huge terminal builds.
  • Executed make -C src/testdir test_messages test_cmdline test_normal test_terminal codestyle via PTY (on Linux as a non-root user); all target suites passed on both platforms.
  • Known skips: Platform/feature-dependent skips remain as expected (Test_echo_verbose_system is skipped on macOS per its existing CheckNotMac guard, but executes and passes on Linux).
  • Code formatting: git diff --check is clean.
  • Scope limitations: No Windows or GUI validation was performed.
  • These are related suites, not the full Vim test suite.

@h-east

h-east commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

The msg_sb_eol() change is not covered by the new test

The comment in the new test says the single newline case checks that
no extra empty line is introduced. I reverted only the msg_sb_eol()
hunk and the new test still passes, newline_count 1 included. What
fails is the existing Test_echo_verbose_system(). So the comment
claims something the loop does not check. Please drop it, or point
to Test_echo_verbose_system() instead.

g< also changes

With this PR, g< (and G at the more prompt) shows the trailing
empty lines of a message, as they were on the screen:

:echo "a\n"
" press Enter, then g<

master shows "a" and the prompt right below it; this PR shows the
empty line between them, like the screen did. That is right, but it
is a visible change that the description does not mention and no test
covers. A g< step in the new test would pin it down.

Comment in msg_puts_display()

"including empty lines" refers to the condition that was removed.
Without it the line reads fine:

    // Store the text for scroll back.

Commit message

The subject should state the problem, and the body needs the
Problem:/Solution: lines. A pull request template was added about a
week ago and covers this, including the AI disclosure:
6918007
Could you fill it in?

@akasakariko

Copy link
Copy Markdown
Author

I'll address these

Problem:  Message pager drops blank separators when scrolling back.
Solution: Store standalone newline chunks during message display and
          avoid adding an extra blank line in msg_sb_eol() when a trailing
          newline exists (KayanoLiam).

When scrolling back through message output in the pager using 'b' or
PageUp, blank lines acting as separators are omitted. Standalone newline
chunks were not stored in msg_puts_display(), causing scrollback history
to drop empty lines. In addition, msg_sb_eol() is guarded to avoid adding
a spurious blank line when a trailing newline already exists, ensuring
trailing empty lines are preserved by 'G' at the more prompt and 'g<'
after Enter.

OpenAI Codex assisted investigation, code and test changes, and validation.
Antigravity Gemini 3.8 Flash drafted the title and body.

fixes:   vim#21315
closes:  vim#21444

Assisted-by: OpenAI Codex
Assisted-by: Antigravity Gemini 3.8 Flash
@akasakariko
akasakariko force-pushed the fix/more-prompt-empty-lines branch from 8fe0460 to bcdd3cb Compare October 6, 2026 10:07
@akasakariko akasakariko changed the title message: preserve empty lines when redrawing message scrollback Message pager drops blank separators when scrolling back Oct 6, 2026
@akasakariko

Copy link
Copy Markdown
Author

Updated in bcdd3cb:

  • Removed the misleading single-newline test comment and identified Test_echo_verbose_system() as the coverage for msg_sb_eol().
  • Added G / g< regression coverage for zero through three trailing newlines, and documented the visible behavior in the description.
  • Simplified the scrollback storage comment.
  • Reworded the commit subject to state the problem and added Problem:/Solution: lines, the PR template, and AI disclosure.

Confirmed both regression tests fail with the pre-PR implementation. Reverting only the msg_sb_eol() change reproduces the existing verbose-system test failure. The messages, cmdline, normal, terminal, and codestyle suites pass on macOS and Linux (Colima), with platform/feature skips. New CI results are pending.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

more-prompt pager swallows empty newlines when scrolling up (PageUp / b)

2 participants