diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-06-27 08:55:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-27 08:55:59 +0800 |
commit | 2e055e49a3ae27db641986650aa9e7b2b962cf63 (patch) | |
tree | 421d42a6c3d86e11cf37af09175ccb789c069214 /src | |
parent | 0ca2d11c1f473d9924c261c9dbd4e38730932bb4 (diff) | |
parent | 116b09ac0495f07cb42a0b034622b6122d4ea0f8 (diff) | |
download | rneovim-2e055e49a3ae27db641986650aa9e7b2b962cf63.tar.gz rneovim-2e055e49a3ae27db641986650aa9e7b2b962cf63.tar.bz2 rneovim-2e055e49a3ae27db641986650aa9e7b2b962cf63.zip |
Merge pull request #24170 from zeertzjq/vim-9.0.1664
vim-patch:9.0.{1664,1667}: divide by zero when scrolling with 'smoothscroll' set
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/move.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c index f859294d65..cc02808e4c 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1954,17 +1954,19 @@ void scroll_cursor_bot(int min_scroll, int set_topbot) int top_plines = plines_win_nofill(curwin, curwin->w_topline, false); int skip_lines = 0; int width1 = curwin->w_width_inner - curwin_col_off(); - int width2 = width1 + curwin_col_off2(); - // similar formula is used in curs_columns() - if (curwin->w_skipcol > width1) { - skip_lines += (curwin->w_skipcol - width1) / width2 + 1; - } else if (curwin->w_skipcol > 0) { - skip_lines = 1; - } + if (width1 > 0) { + int width2 = width1 + curwin_col_off2(); + // similar formula is used in curs_columns() + if (curwin->w_skipcol > width1) { + skip_lines += (curwin->w_skipcol - width1) / width2 + 1; + } else if (curwin->w_skipcol > 0) { + skip_lines = 1; + } - top_plines -= skip_lines; - if (top_plines > curwin->w_height_inner) { - scrolled += (top_plines - curwin->w_height_inner); + top_plines -= skip_lines; + if (top_plines > curwin->w_height_inner) { + scrolled += (top_plines - curwin->w_height_inner); + } } } } |