Patch 8.2.4555
Problem:    getmousepos() returns the wrong column. (Ernie Rael)
Solution:   Limit to the text size, not the number of bytes.
Files:      src/mouse.c, src/testdir/test_functions.vim


*** ../vim-8.2.4554/src/mouse.c 2021-11-29 17:37:38.063265208 +0000
--- src/mouse.c 2022-03-13 11:54:16.919648342 +0000
***************
*** 3099,3115 ****
            col -= left_off;
            if (row >= 0 && row < wp->w_height && col >= 0 && col < wp->w_width)
            {
-               char_u  *p;
                int     count;
  
                mouse_comp_pos(wp, &row, &col, &line, NULL);
  
!               // limit to text length plus one
!               p = ml_get_buf(wp->w_buffer, line, FALSE);
!               count = (int)STRLEN(p);
                if (col > count)
                    col = count;
- 
                column = col + 1;
            }
        }
--- 3099,3112 ----
            col -= left_off;
            if (row >= 0 && row < wp->w_height && col >= 0 && col < wp->w_width)
            {
                int     count;
  
                mouse_comp_pos(wp, &row, &col, &line, NULL);
  
!               // limit to text size plus one
!               count = linetabsize(ml_get_buf(wp->w_buffer, line, FALSE));
                if (col > count)
                    col = count;
                column = col + 1;
            }
        }
*** ../vim-8.2.4554/src/testdir/test_functions.vim      2022-02-20 
19:05:06.359955597 +0000
--- src/testdir/test_functions.vim      2022-03-13 12:02:00.249657121 +0000
***************
*** 2750,2755 ****
--- 2750,2781 ----
    call assert_equal([0, 0, 0, 0, 0], getcurpos(1999))
  endfunc
  
+ func Test_getmousepos()
+   enew!
+   call setline(1, "\t\t\t1234")
+   call test_setmouse(1, 25)
+   call assert_equal(#{
+         \ screenrow: 1,
+         \ screencol: 25,
+         \ winid: win_getid(),
+         \ winrow: 1,
+         \ wincol: 25,
+         \ line: 1,
+         \ column: 25,
+         \ }, getmousepos())
+   call test_setmouse(1, 50)
+   call assert_equal(#{
+         \ screenrow: 1,
+         \ screencol: 50,
+         \ winid: win_getid(),
+         \ winrow: 1,
+         \ wincol: 50,
+         \ line: 1,
+         \ column: 29,
+         \ }, getmousepos())
+   bwipe!
+ endfunc
+ 
  " Test for glob()
  func Test_glob()
    call assert_equal('', glob(test_null_string()))
*** ../vim-8.2.4554/src/version.c       2022-03-12 21:28:18.532257720 +0000
--- src/version.c       2022-03-13 12:00:39.170223010 +0000
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4555,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
245. You use Real Audio to listen to a radio station from a distant
     city rather than turn on your stereo system.

 /// Bram Moolenaar -- b...@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    ///

-- 
-- 
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 on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220313120830.97B711C79E6%40moolenaar.net.

Raspunde prin e-mail lui