diff options
author | Christian Clason <c.clason@uni-graz.at> | 2023-05-24 10:04:49 +0200 |
---|---|---|
committer | Christian Clason <c.clason@uni-graz.at> | 2024-08-10 10:26:07 +0200 |
commit | 8df6736ca14d09f87cf0a8486758ac5708819434 (patch) | |
tree | 29434767d09bcff3c2e519ad417177d81f7f977f /src | |
parent | fa79a8ad6deefeea81c1959d69aa4c8b2d993f99 (diff) | |
download | rneovim-8df6736ca14d09f87cf0a8486758ac5708819434.tar.gz rneovim-8df6736ca14d09f87cf0a8486758ac5708819434.tar.bz2 rneovim-8df6736ca14d09f87cf0a8486758ac5708819434.zip |
feat(term): enable reflow by default (#21124)
Problem: Contents of terminal buffer are not reflown when Nvim is
resized.
Solution: Enable reflow in libvterm by default. Now that libvterm is
vendored, also fix "TUI rapid resize" test failures there.
Note: Neovim's scrollback buffer does not support reflow (yet), so lines
vanishing into the buffer due to a too small window will be restored
without reflow.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/options.lua | 3 | ||||
-rw-r--r-- | src/nvim/terminal.c | 3 | ||||
-rw-r--r-- | src/vterm/screen.c | 4 |
3 files changed, 6 insertions, 4 deletions
diff --git a/src/nvim/options.lua b/src/nvim/options.lua index ef7cc2fb89..3612a80fb8 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -6627,6 +6627,9 @@ return { top are deleted if new lines exceed this limit. Minimum is 1, maximum is 100000. Only in |terminal| buffers. + + Note: Lines that are not visible and kept in scrollback are not + reflown when the terminal buffer is resized horizontally. ]=], full_name = 'scrollback', redraw = { 'current_buffer' }, diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index abc9b3534b..54a0de9c22 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -319,8 +319,7 @@ void terminal_open(Terminal **termpp, buf_T *buf, TerminalOptions opts) // Set up screen term->vts = vterm_obtain_screen(term->vt); vterm_screen_enable_altscreen(term->vts, true); - // TODO(clason): reenable when https://github.com/neovim/neovim/issues/23762 is fixed - // vterm_screen_enable_reflow(term->vts, true); + vterm_screen_enable_reflow(term->vts, true); // delete empty lines at the end of the buffer vterm_screen_set_callbacks(term->vts, &vterm_screen_callbacks, term); vterm_screen_set_unrecognised_fallbacks(term->vts, &vterm_fallbacks, term); diff --git a/src/vterm/screen.c b/src/vterm/screen.c index 97a8d50b93..720d1bb939 100644 --- a/src/vterm/screen.c +++ b/src/vterm/screen.c @@ -534,7 +534,7 @@ static void resize_buffer(VTermScreen *screen, int bufidx, int new_rows, int new while(old_row >= 0) { int old_row_end = old_row; /* TODO: Stop if dwl or dhl */ - while(REFLOW && old_lineinfo && old_row >= 0 && old_lineinfo[old_row].continuation) + while(REFLOW && old_lineinfo && old_row > 0 && old_lineinfo[old_row].continuation) old_row--; int old_row_start = old_row; @@ -596,7 +596,7 @@ static void resize_buffer(VTermScreen *screen, int bufidx, int new_rows, int new #endif if(new_row_start < 0) { - if(old_row_start <= old_cursor.row && old_cursor.row < old_row_end) { + if(old_row_start <= old_cursor.row && old_cursor.row <= old_row_end) { new_cursor.row = 0; new_cursor.col = old_cursor.col; if(new_cursor.col >= new_cols) |