To: vim_dev@googlegroups.com Subject: Patch 9.0.1247 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1247 Problem: Divide by zero with 'smoothscroll' set and a narrow window. Solution: Bail out when the window is too narrow. Files: src/move.c, src/testdir/test_scroll_opt.vim src/testdir/dumps/Test_smoothscroll_zero_1.dump, src/testdir/dumps/Test_smoothscroll_zero_2.dump *** ../vim-9.0.1246/src/move.c 2023-01-14 12:32:24.219984103 +0000 --- src/move.c 2023-01-26 14:10:54.127578790 +0000 *************** *** 1933,1938 **** --- 1933,1941 ---- return; int width1 = curwin->w_width - curwin_col_off(); + if (width1 <= 0) + return; // no text will be displayed + int width2 = width1 + curwin_col_off2(); long so = get_scrolloff_value(); int scrolloff_cols = so == 0 ? 0 : width1 + (so - 1) * width2; *** ../vim-9.0.1246/src/testdir/test_scroll_opt.vim 2022-12-31 15:12:58.046637322 +0000 --- src/testdir/test_scroll_opt.vim 2023-01-26 14:08:32.615642254 +0000 *************** *** 560,564 **** --- 560,591 ---- let &ttymouse = save_ttymouse endfunc + " this was dividing by zero + func Test_smoothscrol_zero_width() + CheckScreendump + + let lines =<< trim END + winsize 0 0 + vsplit + vsplit + vsplit + vsplit + vsplit + sil norm H + set wrap + set smoothscroll + set number + END + call writefile(lines, 'XSmoothScrollZero', 'D') + let buf = RunVimInTerminal('-u NONE -i NONE -n -m -X -Z -e -s -S XSmoothScrollZero', #{rows: 6, cols: 60, wait_for_ruler: 0}) + call TermWait(buf, 3000) + call VerifyScreenDump(buf, 'Test_smoothscroll_zero_1', {}) + + call term_sendkeys(buf, ":sil norm \\\\\") + call VerifyScreenDump(buf, 'Test_smoothscroll_zero_2', {}) + + call StopVimInTerminal(buf) + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.1246/src/testdir/dumps/Test_smoothscroll_zero_1.dump 2023-01-26 14:14:06.347490220 +0000 --- src/testdir/dumps/Test_smoothscroll_zero_1.dump 2023-01-26 14:08:56.007631886 +0000 *************** *** 0 **** --- 1,6 ---- + > +0&#ffffff0@59 + @60 + @60 + @60 + @60 + @60 *** ../vim-9.0.1246/src/testdir/dumps/Test_smoothscroll_zero_2.dump 2023-01-26 14:14:06.351490218 +0000 --- src/testdir/dumps/Test_smoothscroll_zero_2.dump 2023-01-26 14:08:57.775631098 +0000 *************** *** 0 **** --- 1,6 ---- + |:+0&#ffffff0|s|i|l| |n|o|r|m| |^|W|^|N| @45 + > @59 + @60 + @60 + @60 + @60 *** ../vim-9.0.1246/src/version.c 2023-01-26 11:58:39.606071598 +0000 --- src/version.c 2023-01-26 13:09:01.013613378 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1247, /**/ -- There is a difference between "should work" and "does work", it's called testing. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///