patch 9.1.1062: terminal: E315 when dragging the terminal with the mouse

Commit: 
https://github.com/vim/vim/commit/3219da514c1f90b0883158d044512641407eacd6
Author: Hirohito Higashi <h.east....@gmail.com>
Date:   Sat Feb 1 14:48:35 2025 +0100

    patch 9.1.1062: terminal: E315 when dragging the terminal with the mouse
    
    Problem:  terminal: E315 when dragging the terminal with the mouse
              (user202729)
    Solution: call update_topline() and validate_cursor() when clicking
              on the status line with the mouse (Hirohito Higashi)
    
    fixes: #16024
    fixes: #16211
    closes: #16552
    
    Signed-off-by: Hirohito Higashi <h.east....@gmail.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/mouse.c b/src/mouse.c
index 4e10e723e..3bdb1025e 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -1902,6 +1902,16 @@ retnomove:
            // Drag the status line
            count = row - W_WINROW(dragwin) - dragwin->w_height + 1
                                                             - on_status_line;
+#ifdef FEAT_TERMINAL
+           if (bt_terminal(dragwin->w_buffer))
+           {
+               win_T *curwin_save = curwin;
+               curwin = dragwin;
+               update_topline();
+               validate_cursor();
+               curwin = curwin_save;
+           }
+#endif
            win_drag_status_line(dragwin, count);
            did_drag |= count;
        }
diff --git a/src/testdir/test_terminal2.vim b/src/testdir/test_terminal2.vim
index 9413905a9..57944bedf 100644
--- a/src/testdir/test_terminal2.vim
+++ b/src/testdir/test_terminal2.vim
@@ -289,6 +289,61 @@ func Test_termwinscroll_topline()
   set termwinscroll& mouse&
 endfunc
 
+func Test_termwinscroll_topline2()
+  let g:test_is_flaky = 1
+  set termwinscroll=75000 mouse=a
+  if !has('win32')
+    set shell=sh
+  endif
+  let norm_winid = win_getid()
+  terminal
+  call assert_equal(2, winnr('$'))
+  let buf = bufnr()
+  let win = winnr()
+  call WaitFor({-> !empty(term_getline(buf, 1))})
+
+  let num1 = &termwinscroll / 1000 * 999
+  call writefile(range(num1), 'Xtext', 'D')
+  if has('win32')
+    call term_sendkeys(buf, "type Xtext\<CR>")
+  else
+    call term_sendkeys(buf, "cat Xtext\<CR>")
+  endif
+  let rows = term_getsize(buf)[0]
+  " It may take a while to finish on a slow system
+  call term_wait(buf, 1000 * g:run_nr)
+  " On MS-Windows there is an empty line, check both last line and above it.
+  call WaitForAssert({-> assert_match(string(num1 - 1), term_getline(buf, rows 
- 1) .. '\|' .. term_getline(buf, rows - 2))})
+  call feedkeys("\<C-W>N", 'xt')
+  call feedkeys("i", 'xt')
+
+  let num2 = &termwinscroll / 1000 * 8
+  call writefile(range(num2), 'Xtext', 'D')
+  if has('win32')
+    call term_sendkeys(buf, "timeout /t 2 && type Xtext\<CR>")
+  else
+    call term_sendkeys(buf, "sleep 2; cat Xtext\<CR>")
+  endif
+  let winrow = get(get(filter(getwininfo(), 'v:val.winid == norm_winid'), 0, 
{}), 'winrow', -1)
+
+  call test_setmouse(winrow, 1)
+  call feedkeys("\<LeftMouse>", "xt")
+  call WaitForAssert({-> assert_notequal(buf, bufnr())})
+
+  " Change the terminal window row size
+  call win_move_statusline(win,1)
+  " Before the fix, E340 and E315 would occur multiple times at this point.
+  let winrow2 = get(get(filter(getwininfo(), 'v:val.winid == norm_winid'), 0, 
{}), 'winrow', -1)
+  call assert_equal(winrow + 1, winrow2)
+
+  call test_setmouse(1, 1)
+  call feedkeys("\<LeftMouse>", "xt")
+  call WaitForAssert({-> assert_equal(buf, bufnr())})
+
+  exe buf . 'bwipe!'
+  set termwinscroll& mouse& sh&
+endfunc
+
 " Resizing the terminal window caused an ml_get error.
 " TODO: This does not reproduce the original problem.
 " TODO: This test starts timing out in Github CI Gui test, why????
diff --git a/src/version.c b/src/version.c
index b384a7398..d59ce56b7 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1062,
 /**/
     1061,
 /**/

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1teE2W-00GLna-BV%40256bit.org.

Raspunde prin e-mail lui