Patch 8.2.4559 (after 8.24555)
Problem:    getmousepos() returns the screen column. (Ernie Rael)
Solution:   Return the text column, as documented.
Files:      src/mouse.c, src/testdir/test_functions.vim


*** ../vim-8.2.4558/src/mouse.c 2022-03-13 12:06:02.076218096 +0000
--- src/mouse.c 2022-03-13 15:47:50.130233218 +0000
***************
*** 3065,3071 ****
      varnumber_T winid = 0;
      varnumber_T winrow = 0;
      varnumber_T wincol = 0;
!     linenr_T  line = 0;
      varnumber_T column = 0;
  
      if (rettv_dict_alloc(rettv) != OK)
--- 3065,3071 ----
      varnumber_T winid = 0;
      varnumber_T winrow = 0;
      varnumber_T wincol = 0;
!     linenr_T  lnum = 0;
      varnumber_T column = 0;
  
      if (rettv_dict_alloc(rettv) != OK)
***************
*** 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;
            }
        }
--- 3099,3106 ----
            col -= left_off;
            if (row >= 0 && row < wp->w_height && col >= 0 && col < wp->w_width)
            {
!               if (!mouse_comp_pos(wp, &row, &col, &lnum, NULL))
!                   col = vcol2col(wp, lnum, col);
                column = col + 1;
            }
        }
***************
*** 3114,3120 ****
      dict_add_number(d, "winid", winid);
      dict_add_number(d, "winrow", winrow);
      dict_add_number(d, "wincol", wincol);
!     dict_add_number(d, "line", (varnumber_T)line);
      dict_add_number(d, "column", column);
  }
  #endif
--- 3108,3114 ----
      dict_add_number(d, "winid", winid);
      dict_add_number(d, "winrow", winrow);
      dict_add_number(d, "wincol", wincol);
!     dict_add_number(d, "line", (varnumber_T)lnum);
      dict_add_number(d, "column", column);
  }
  #endif
*** ../vim-8.2.4558/src/testdir/test_functions.vim      2022-03-13 
12:06:02.076218096 +0000
--- src/testdir/test_functions.vim      2022-03-13 15:49:41.633915091 +0000
***************
*** 2753,2758 ****
--- 2753,2768 ----
  func Test_getmousepos()
    enew!
    call setline(1, "\t\t\t1234")
+   call test_setmouse(1, 1)
+   call assert_equal(#{
+         \ screenrow: 1,
+         \ screencol: 1,
+         \ winid: win_getid(),
+         \ winrow: 1,
+         \ wincol: 1,
+         \ line: 1,
+         \ column: 1,
+         \ }, getmousepos())
    call test_setmouse(1, 25)
    call assert_equal(#{
          \ screenrow: 1,
***************
*** 2761,2767 ****
          \ winrow: 1,
          \ wincol: 25,
          \ line: 1,
!         \ column: 25,
          \ }, getmousepos())
    call test_setmouse(1, 50)
    call assert_equal(#{
--- 2771,2777 ----
          \ winrow: 1,
          \ wincol: 25,
          \ line: 1,
!         \ column: 4,
          \ }, getmousepos())
    call test_setmouse(1, 50)
    call assert_equal(#{
***************
*** 2771,2777 ****
          \ winrow: 1,
          \ wincol: 50,
          \ line: 1,
!         \ column: 29,
          \ }, getmousepos())
    bwipe!
  endfunc
--- 2781,2787 ----
          \ winrow: 1,
          \ wincol: 50,
          \ line: 1,
!         \ column: 8,
          \ }, getmousepos())
    bwipe!
  endfunc
*** ../vim-8.2.4558/src/version.c       2022-03-13 14:44:59.400422412 +0000
--- src/version.c       2022-03-13 15:52:10.441496216 +0000
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4559,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
251. You've never seen your closest friends who usually live WAY too far away.

 /// 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/20220313155355.74A411C79E4%40moolenaar.net.

Raspunde prin e-mail lui