[vim/vim] Enable terminal reflow on resize (PR #19863)

8 views
Skip to first unread message

mattn

unread,
Mar 30, 2026, 8:00:56 AM (9 days ago) Mar 30
to vim/vim, Subscribed

Enable vterm_screen_enable_reflow() so that long lines in a terminal window reflow (re-wrap) when the terminal is resized. Added tests for both ASCII and multibyte (CJK) characters.

Fixes #2865


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/19863

Commit Summary

  • 1409a06 Enable terminal reflow on resize

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863@github.com>

mattn

unread,
Mar 30, 2026, 8:39:51 AM (9 days ago) Mar 30
to vim/vim, Push

@mattn pushed 1 commit.

  • 0cf96e6 Join continuation lines in Terminal-Normal mode buffer


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863/before/1409a0635573cadeebc8f75881b08c934bbb53b1/after/0cf96e6305aef26f77a06926e958ae4c6c9c4ecd@github.com>

mattn

unread,
Mar 30, 2026, 9:02:47 AM (9 days ago) Mar 30
to vim/vim, Push

@mattn pushed 1 commit.

  • 8604449 Fix reflow tests to not hardcode terminal row numbers


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863/before/0cf96e6305aef26f77a06926e958ae4c6c9c4ecd/after/86044492a16fc8fd1c8258240b12aeaaec5ccd96@github.com>

Cimbali

unread,
Mar 30, 2026, 9:08:53 AM (9 days ago) Mar 30
to vim/vim, Subscribed
Cimbali left a comment (vim/vim#19863)

This is nice but still missing the bit that also unwraps lines that have been scrolled out of the current viewport:

image.png (view on web)

I am now at line 30 so line 18 reflowed nicely, but line 1 that wasn’t on-screen as the switch happened (already pushed into the scrollback buffer) is broken.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863/c4154915205@github.com>

mattn

unread,
Mar 30, 2026, 9:16:46 AM (9 days ago) Mar 30
to vim/vim, Subscribed
mattn left a comment (vim/vim#19863)

@Cimbali Thanks for testing! I just pushed a new commit that also joins continuation lines in the scrollback buffer (lines pushed off the top of the screen). This adds a vterm_screen_sb_pushline_continuation() accessor to libvterm so that handle_pushline can detect and join continuation lines when they're scrolled out of the viewport. Please try again with the latest commit.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863/c4154965602@github.com>

mattn

unread,
Mar 30, 2026, 9:16:52 AM (9 days ago) Mar 30
to vim/vim, Push

@mattn pushed 1 commit.

  • 9f0ea1a Join continuation lines in scrollback buffer


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863/before/86044492a16fc8fd1c8258240b12aeaaec5ccd96/after/9f0ea1a5638dde941ba9835595c8c2fe83f79444@github.com>

mattn

unread,
Mar 30, 2026, 9:23:29 AM (9 days ago) Mar 30
to vim/vim, Subscribed
mattn left a comment (vim/vim#19863)

I'll be looking for corner case bugs for a while, so it might not work for a short time. but I'll fix this soon.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863/c4155011054@github.com>

mattn

unread,
Mar 30, 2026, 9:31:45 AM (9 days ago) Mar 30
to vim/vim, Push

@mattn pushed 1 commit.

  • 5a4a6c0 Fix scrollback continuation detection for shifted lineinfo


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863/before/9f0ea1a5638dde941ba9835595c8c2fe83f79444/after/5a4a6c09c14639a226208400b6e24564c0237d79@github.com>

mattn

unread,
Mar 30, 2026, 9:45:30 AM (9 days ago) Mar 30
to vim/vim, Push

@mattn pushed 1 commit.

  • f065b3b Fix unused variable warning in screen.c


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863/before/5a4a6c09c14639a226208400b6e24564c0237d79/after/f065b3bc2632cb60661d4c13ea7245f0abebaafc@github.com>

mattn

unread,
Mar 30, 2026, 10:01:38 AM (9 days ago) Mar 30
to vim/vim, Push

@mattn pushed 1 commit.

  • 34ac747 Fix flaky Test_terminal_eof_arg on FreeBSD


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863/before/f065b3bc2632cb60661d4c13ea7245f0abebaafc/after/34ac747426986b077b5e51fda83dd3855b6459f0@github.com>

mattn

unread,
Mar 30, 2026, 10:15:39 AM (8 days ago) Mar 30
to vim/vim, Push

@mattn pushed 1 commit.

  • 508e6f9 Fix multibyte reflow tests for FreeBSD


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863/before/34ac747426986b077b5e51fda83dd3855b6459f0/after/508e6f913f19abf7f07ccf170c0ecb12b2d21bf2@github.com>

mattn

unread,
Mar 30, 2026, 10:45:10 AM (8 days ago) Mar 30
to vim/vim, Push

@mattn pushed 1 commit.

  • fe62c57 Fix multibyte reflow tests for macOS


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863/before/508e6f913f19abf7f07ccf170c0ecb12b2d21bf2/after/fe62c57bbcaf5453732c88740ece1ae5efd901ef@github.com>

mattn

unread,
Mar 30, 2026, 11:04:28 AM (8 days ago) Mar 30
to vim/vim, Push

@mattn pushed 1 commit.

  • febdb03 Remove multibyte reflow tests


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863/before/fe62c57bbcaf5453732c88740ece1ae5efd901ef/after/febdb03f90cca27b970b5482795d42573ae9b043@github.com>

mattn

unread,
Mar 30, 2026, 11:05:56 AM (8 days ago) Mar 30
to vim/vim, Push

@mattn pushed 1 commit.

  • 94f0775 Remove multibyte reflow tests


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863/before/febdb03f90cca27b970b5482795d42573ae9b043/after/94f077592c58a765763d97c7a3a65b9bab78993e@github.com>

mattn

unread,
Mar 30, 2026, 11:39:52 AM (8 days ago) Mar 30
to vim/vim, Push

@mattn pushed 1 commit.

  • b96a594 Use WaitForAssert for terminal output in reflow tests


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863/before/94f077592c58a765763d97c7a3a65b9bab78993e/after/b96a594c5c82fc5aa12d8259cb9763070e487cd1@github.com>

Christian Brabandt

unread,
4:54 PM (5 hours ago) 4:54 PM
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19863)

How does this differ from #8365 ?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863/c4202142380@github.com>

mattn

unread,
7:55 PM (2 hours ago) 7:55 PM
to vim/vim, Subscribed
mattn left a comment (vim/vim#19863)

@chrisbra
I asked Claude Code about it. I haven’t verified whether the findings are correct.


PR #8365 vs PR #19863 Comparison

Both PRs fix the same issue #2865 — joining soft-wrapped (continuation) lines in the terminal buffer into single lines when switching to Normal mode.

Approach Differences

#8365 (Cimbali) #19863 (mattn)
Started June 2021 March 2026
libvterm changes New sb_pushline4 callback + premove callback (coordinated with upstream author leonerd) New vterm_screen_sb_pushline_continuation() accessor function
ABI compatibility Adds sb_pushline4 while keeping old sb_pushline (ABI-compatible) Calls vterm_screen_sb_pushline_continuation() from within existing sb_pushline callback
Reflow support None (explicitly states resize reflow is not handled) Enables vterm_screen_enable_reflow() (re-wraps on resize)
Files changed 13 files 6 files
Upstream coordination leonerd implemented in upstream libvterm (rev 843) in July 2024 No upstream coordination (custom extension)
Tests libvterm tests + Vim tests Vim tests only

#8365 Strengths and Weaknesses

Strengths:

  • Coordinated with upstream libvterm (leonerd), already merged as rev 843
  • premove callback provides accurate continuation info when lines scroll out of the viewport
  • Includes libvterm-level tests
  • scrollbackline_pos_in_buf() / bufline_pos_in_scrollback() provide bidirectional mapping so term_getline(), term_scrape(), term_get_attr() etc. work correctly with joined lines

Weaknesses:

  • PR spans 5 years with complex code (large changeset across 13 files)
  • Does not support reflow (re-wrapping on terminal resize)
  • Must skip tests on Windows because cmd.exe does not emit continuation marks

#19863 Strengths and Weaknesses

Strengths:

  • Simpler code (6 files, smaller changeset)
  • Supports reflow on resize via vterm_screen_enable_reflow()
  • Clean, modern implementation

Weaknesses:

  • No upstream libvterm coordination — adds a custom sb_pushline_continuation flag. Since #8365 already has an official upstream API (sb_pushline4) implemented by leonerd, this custom extension will conflict when syncing with upstream libvterm in the future
  • Scrollback handling may be incomplete — Cimbali pointed out in comments that lines already scrolled out of the viewport were not being joined. A follow-up commit addressed this, but #8365 more comprehensively fixes term_getline(), term_scrape(), term_get_attr() and other functions that need to account for the line number offset caused by joining
  • term_getline() and term_scrape() fixes may be missing#8365 uses scrollback-to-buffer mapping functions throughout multiple call sites, while #19863's coverage of these edge cases appears more limited

Overall Assessment

From a practical standpoint, #19863 is attractive for its simplicity and reflow support. However, from an upstream compatibility standpoint, #8365 has a clear advantage since leonerd already implemented the sb_pushline4 API in upstream libvterm. The custom extension in #19863 will cause issues when syncing Vim's libvterm fork with upstream in the future.

Ideally, the best approach would be to use #8365's upstream-coordinated libvterm changes as the base and combine them with #19863's reflow enablement. chrisbra also asked in #19863 "How does this differ from #8365?", indicating that reconciliation between the two PRs is needed.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19863/c4202881981@github.com>

Reply all
Reply to author
Forward
0 new messages