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 \<C-V>\<C-W>\<C-V>\<C-N>\<CR>")
+   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 -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230126141615.963491C061F%40moolenaar.net.

Raspunde prin e-mail lui