To: vim_dev@googlegroups.com Subject: Patch 9.0.1664 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1664 Problem: Divide by zero when scrolling with 'smoothscroll' set. Solution: Avoid using a negative width. (closes #12540, closes #12528) Files: src/move.c, src/testdir/test_scroll_opt.vim, src/testdir/dumps/Test_smoothscroll_zero_bot.dump *** ../vim-9.0.1663/src/move.c 2023-06-05 20:44:34.734261086 +0100 --- src/move.c 2023-06-24 21:26:52.197184691 +0100 *************** *** 2591,2607 **** (curwin, curwin->w_topline, FALSE); int skip_lines = 0; int width1 = curwin->w_width - 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; ! ! top_plines -= skip_lines; ! if (top_plines > curwin->w_height) { ! scrolled += (top_plines - curwin->w_height); } } } --- 2591,2610 ---- (curwin, curwin->w_topline, FALSE); int skip_lines = 0; int width1 = curwin->w_width - curwin_col_off(); ! 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) ! { ! scrolled += (top_plines - curwin->w_height); ! } } } } *** ../vim-9.0.1663/src/testdir/test_scroll_opt.vim 2023-06-05 20:44:34.734261086 +0100 --- src/testdir/test_scroll_opt.vim 2023-06-24 21:53:20.891302303 +0100 *************** *** 833,836 **** --- 833,860 ---- call StopVimInTerminal(buf) endfunc + " this was dividing by zero bug in scroll_cursor_bot + func Test_smoothscroll_zero_width_scroll_cursor_bot() + CheckScreendump + + let lines =<< trim END + silent normal yy + silent normal 19p + winsize 0 19 + vsplit + vertical resize 0 + set foldcolumn=1 + set number + set smoothscroll + silent normal 20G + END + call writefile(lines, 'XSmoothScrollZeroBot', 'D') + let buf = RunVimInTerminal('-u NONE -S XSmoothScrollZeroBot', #{rows: 19, wait_for_ruler: 0}) + call TermWait(buf, 1000) + + call VerifyScreenDump(buf, 'Test_smoothscroll_zero_bot', {}) + + call StopVimInTerminal(buf) + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-9.0.1663/src/testdir/dumps/Test_smoothscroll_zero_bot.dump 2023-06-24 21:57:31.519185073 +0100 --- src/testdir/dumps/Test_smoothscroll_zero_bot.dump 2023-06-24 21:26:52.197184691 +0100 *************** *** 0 **** --- 1,19 ---- + | +0#af5f00255#ffffff0||+1#0000000&| +0&&@9 + |@+0#4040ff13&||+1#0000000&| +0&&@9 + |@+0#4040ff13&||+1#0000000&| +0&&@9 + |@+0#4040ff13&||+1#0000000&| +0&&@9 + |@+0#4040ff13&||+1#0000000&| +0&&@9 + |@+0#4040ff13&||+1#0000000&| +0&&@9 + |@+0#4040ff13&||+1#0000000&| +0&&@9 + |@+0#4040ff13&||+1#0000000&| +0&&@9 + |@+0#4040ff13&||+1#0000000&| +0&&@9 + |@+0#4040ff13&||+1#0000000&| +0&&@9 + |@+0#4040ff13&||+1#0000000&| +0&&@9 + |@+0#4040ff13&||+1#0000000&| +0&&@9 + |@+0#4040ff13&||+1#0000000&| +0&&@9 + |@+0#4040ff13&||+1#0000000&| +0&&@9 + |@+0#4040ff13&||+1#0000000&| +0&&@9 + |@+0#4040ff13&||+1#0000000&| +0&&@9 + >@+0#4040ff13&||+1#0000000&| +0&&@9 + |<+3&&| |<+1&&|a|m|e|]| |[|+|]| + | +0&&@11 *** ../vim-9.0.1663/src/version.c 2023-06-24 20:02:21.503021810 +0100 --- src/version.c 2023-06-24 21:57:12.587193552 +0100 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1664, /**/ -- The term "free software" is defined by Richard M. Stallman as being software that isn't necessarily for free. Confusing? Let's call it "Stallman software" then! -- Bram Moolenaar /// 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 ///