diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-10-03 10:23:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-03 10:23:03 +0800 |
commit | e1157324657907fab37de8dea71442802d222dd3 (patch) | |
tree | ac2ad30f54d4260bc8e3acc83235c9754b12a7d4 | |
parent | 3c76038755b5c0c63604f2baa481491bb0efe2e1 (diff) | |
download | rneovim-e1157324657907fab37de8dea71442802d222dd3.tar.gz rneovim-e1157324657907fab37de8dea71442802d222dd3.tar.bz2 rneovim-e1157324657907fab37de8dea71442802d222dd3.zip |
fix(terminal): check terminal size at end of screen update (#25480)
-rw-r--r-- | src/nvim/drawscreen.c | 18 | ||||
-rw-r--r-- | test/functional/terminal/window_spec.lua | 41 |
2 files changed, 46 insertions, 13 deletions
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index cc22accf2b..a0cbc60f25 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -1519,16 +1519,12 @@ static void win_update(win_T *wp, DecorProviders *providers) } } - // Force redraw when width of 'number' or 'relativenumber' column - // changes. - int nrwidth = (wp->w_p_nu || wp->w_p_rnu || *wp->w_p_stc) ? number_width(wp) : 0; - if (wp->w_nrwidth != nrwidth) { + const int nrwidth_before = wp->w_nrwidth; + int nrwidth_new = (wp->w_p_nu || wp->w_p_rnu || *wp->w_p_stc) ? number_width(wp) : 0; + // Force redraw when width of 'number' or 'relativenumber' column changes. + if (wp->w_nrwidth != nrwidth_new) { type = UPD_NOT_VALID; - wp->w_nrwidth = nrwidth; - - if (buf->terminal) { - terminal_check_size(buf->terminal); - } + wp->w_nrwidth = nrwidth_new; } else if (buf->b_mod_set && buf->b_mod_xlines != 0 && wp->w_redraw_top != 0) { @@ -2498,6 +2494,10 @@ static void win_update(win_T *wp, DecorProviders *providers) } } + if (nrwidth_before != wp->w_nrwidth && buf->terminal) { + terminal_check_size(buf->terminal); + } + // restore got_int, unless CTRL-C was hit while redrawing if (!got_int) { got_int = save_got_int; diff --git a/test/functional/terminal/window_spec.lua b/test/functional/terminal/window_spec.lua index f90e4f7e9d..39fc2c2562 100644 --- a/test/functional/terminal/window_spec.lua +++ b/test/functional/terminal/window_spec.lua @@ -44,7 +44,7 @@ describe(':terminal window', function() {7:6 } | {3:-- TERMINAL --} | ]]) - feed_data({'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'}) + feed_data('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') screen:expect([[ {7:1 }tty ready | {7:2 }rows: 6, cols: 48 | @@ -55,8 +55,6 @@ describe(':terminal window', function() {3:-- TERMINAL --} | ]]) - skip(is_os('win'), 'win: :terminal resize is unreliable #7007') - -- numberwidth=9 feed([[<C-\><C-N>]]) feed([[:set numberwidth=9 number<CR>i]]) @@ -69,7 +67,7 @@ describe(':terminal window', function() {7: 6 } | {3:-- TERMINAL --} | ]]) - feed_data({' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'}) + feed_data(' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') screen:expect([[ {7: 1 }tty ready | {7: 2 }rows: 6, cols: 48 | @@ -82,6 +80,41 @@ describe(':terminal window', function() end) end) + describe("with 'statuscolumn'", function() + it('wraps text', function() + command([[set number statuscolumn=++%l\ \ ]]) + screen:expect([[ + {7:++1 }tty ready | + {7:++2 }rows: 6, cols: 45 | + {7:++3 }{1: } | + {7:++4 } | + {7:++5 } | + {7:++6 } | + {3:-- TERMINAL --} | + ]]) + feed_data('\n\n\n\n\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') + screen:expect([[ + {7:++4 } | + {7:++5 } | + {7:++6 } | + {7:++7 } | + {7:++8 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS| + {7:++9 }TUVWXYZ{1: } | + {3:-- TERMINAL --} | + ]]) + feed_data('\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') + screen:expect([[ + {7:++7 } | + {7:++8 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR| + {7:++9 }STUVWXYZ | + {7:++10 }abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR| + {7:++11 }STUVWXYZrows: 6, cols: 44 | + {7:++12 }{1: } | + {3:-- TERMINAL --} | + ]]) + end) + end) + describe("with 'colorcolumn'", function() before_each(function() feed([[<C-\><C-N>]]) |