Patch 9.0.0824
Problem:    Crash when using win_move_separator() in other tab page.
Solution:   Check for valid window in current tab page.
            (closes #11479, closes #11427)
Files:      src/evalwindow.c, src/testdir/test_mapping.vim,
            src/testdir/test_window_cmd.vim


*** ../vim-9.0.0823/src/evalwindow.c    2022-10-31 12:24:04.098680850 +0000
--- src/evalwindow.c    2022-11-01 11:36:28.838371162 +0000
***************
*** 889,894 ****
--- 889,899 ----
      wp = find_win_by_nr_or_id(&argvars[0]);
      if (wp == NULL || win_valid_popup(wp))
        return;
+     if (!win_valid(wp))
+     {
+       emsg(_(e_cannot_resize_window_in_another_tab_page));
+       return;
+     }
  
      offset = (int)tv_get_number(&argvars[1]);
      win_drag_vsep_line(wp, offset);
*** ../vim-9.0.0823/src/testdir/test_mapping.vim        2022-10-31 
13:04:59.497449003 +0000
--- src/testdir/test_mapping.vim        2022-11-01 11:36:28.838371162 +0000
***************
*** 1652,1669 ****
    set laststatus=2
    set mouse=a
    func ClickExpr()
!       call test_setmouse(&lines - 1, 1)
!         return "\<LeftMouse>"
    endfunc
    func DragExpr()
!       call test_setmouse(&lines - 2, 1)
!         return "\<LeftDrag>"
    endfunc
    nnoremap <expr> <F2> ClickExpr()
    nnoremap <expr> <F3> DragExpr()
  
    " this was causing a crash in win_drag_status_line()
    call feedkeys("\<F2>:tabnew\<CR>\<F3>", 'tx')
  endfunc
  
  " Test for mapping <LeftDrag> in Insert mode
--- 1652,1675 ----
    set laststatus=2
    set mouse=a
    func ClickExpr()
!     call test_setmouse(&lines - 1, 1)
!     return "\<LeftMouse>"
    endfunc
    func DragExpr()
!     call test_setmouse(&lines - 2, 1)
!     return "\<LeftDrag>"
    endfunc
    nnoremap <expr> <F2> ClickExpr()
    nnoremap <expr> <F3> DragExpr()
  
    " this was causing a crash in win_drag_status_line()
    call feedkeys("\<F2>:tabnew\<CR>\<F3>", 'tx')
+ 
+   nunmap <F2>
+   nunmap <F3>
+   delfunc ClickExpr
+   delfunc DragExpr
+   set laststatus& mouse&
  endfunc
  
  " Test for mapping <LeftDrag> in Insert mode
*** ../vim-9.0.0823/src/testdir/test_window_cmd.vim     2022-10-31 
12:24:04.098680850 +0000
--- src/testdir/test_window_cmd.vim     2022-11-01 11:36:28.838371162 +0000
***************
*** 1483,1505 ****
--- 1483,1515 ----
    call assert_equal(w0, winwidth(0))
    call assert_true(win_move_separator(0, -1))
    call assert_equal(w0, winwidth(0))
+ 
    " check that win_move_separator doesn't error with offsets beyond moving
    " possibility
    call assert_true(win_move_separator(id, 5000))
    call assert_true(winwidth(id) > w)
    call assert_true(win_move_separator(id, -5000))
    call assert_true(winwidth(id) < w)
+ 
    " check that win_move_separator returns false for an invalid window
    wincmd =
    let w = winwidth(0)
    call assert_false(win_move_separator(-1, 1))
    call assert_equal(w, winwidth(0))
+ 
    " check that win_move_separator returns false for a popup window
    let id = popup_create(['hello', 'world'], {})
    let w = winwidth(id)
    call assert_false(win_move_separator(id, 1))
    call assert_equal(w, winwidth(id))
    call popup_close(id)
+ 
+   " check that using another tabpage fails without crash
+   let id = win_getid()
+   tabnew
+   call assert_fails('call win_move_separator(id, -1)', 'E1308:')
+   tabclose
+ 
    %bwipe!
  endfunc
  
*** ../vim-9.0.0823/src/version.c       2022-10-31 23:06:52.004079731 +0000
--- src/version.c       2022-11-01 11:40:01.814452083 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     824,
  /**/

-- 
The average life of an organization chart is six months.  You can safely
ignore any order from your boss that would take six months to complete.
                                (Scott Adams - The Dilbert principle)

 /// 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/20221101114601.0E5221C0739%40moolenaar.net.

Raspunde prin e-mail lui