patch 9.1.0201: gM not working correctly with virt text

Commit: 
https://github.com/vim/vim/commit/366c81a2005370ac738618d889ec0337397a9f96
Author: Dylan Thacker-Smith <dylan.ah.sm...@gmail.com>
Date:   Sun Mar 24 09:46:56 2024 +0100

    patch 9.1.0201: gM not working correctly with virt text
    
    Problem:  `gM` would include outer virtual text and its padding when
              getting the line length used to calculate the middle of the
              line, putting the cursor much closer to virtual text lines.
    Solution: Exclude outer virtual text in getting the line length for
              `gM`, so that virtual text doesn't influence where the cursor
              is moved to (Dylan Thacker-Smith).
    
    closes: #14262
    
    Signed-off-by: Dylan Thacker-Smith <dylan.ah.sm...@gmail.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/normal.c b/src/normal.c
index 531b6f9fb..fcd6311c7 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -6066,7 +6066,7 @@ nv_g_cmd(cmdarg_T *cap)
        {
            oap->motion_type = MCHAR;
            oap->inclusive = FALSE;
-           i = linetabsize(curwin, curwin->w_cursor.lnum);
+           i = linetabsize_no_outer(curwin, curwin->w_cursor.lnum);
            if (cap->count0 > 0 && cap->count0 <= 100)
                coladvance((colnr_T)(i * cap->count0 / 100));
            else
diff --git 
a/src/testdir/dumps/Test_prop_normal_gj_gk_over_outer_virtual_text_1.dump 
b/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_1.dump
similarity index 100%
rename from 
src/testdir/dumps/Test_prop_normal_gj_gk_over_outer_virtual_text_1.dump
rename to 
src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_1.dump
diff --git 
a/src/testdir/dumps/Test_prop_normal_gj_gk_over_outer_virtual_text_2.dump 
b/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_2.dump
similarity index 100%
rename from 
src/testdir/dumps/Test_prop_normal_gj_gk_over_outer_virtual_text_2.dump
rename to 
src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_2.dump
diff --git 
a/src/testdir/dumps/Test_prop_normal_gj_gk_over_outer_virtual_text_3.dump 
b/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_3.dump
similarity index 100%
rename from 
src/testdir/dumps/Test_prop_normal_gj_gk_over_outer_virtual_text_3.dump
rename to 
src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_3.dump
diff --git 
a/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_4.dump 
b/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_4.dump
new file mode 100644
index 000000000..2c03fdf79
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_4.dump
@@ -0,0 +1,16 @@
+| +0#af5f00255#ffffff0@3|A+0#0000001#ffff4012|b|o|v|e| +0#0000000#ffffff0@30
+| +0#af5f00255&@1|1| |F+0#0000000&|i|r|s|t| |l|i|n|e| |f|i|t|s> |o|n| 
|s|c|r|e@1|n| |l|i|n|e|.|A+0#0000001#ffff4012|f|t|e|r
+| +0#af5f00255#ffffff0@3| +0#0000001#ffff4012|t|e|x|t| |w|r|a|p|s| |t|o| 
|n|e|x|t| |l|i|n|e|.| +0#0000000#ffffff0@10
+| +0#af5f00255&@3| +0#0000000&@5|R+0#0000001#ffff4012|i|g|h|t| |t|e|x|t| 
|w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.
+| +0#af5f00255#ffffff0@3|B+0#0000001#ffff4012|e|l|o|w| +0#0000000#ffffff0@30
+| +0#af5f00255&@3|A+0#0000001#ffff4012|b|o|v|e| +0#0000000#ffffff0@30
+| +0#af5f00255&@1|2| |A+0#0000001#ffff4012|f|t|e|r| |t|e|x|t| |w|r|a|p|s| 
|t|o| |n|e|x|t| |l|i|n|e|.| +0#0000000#ffffff0@5
+| +0#af5f00255&@3| +0#0000000&@5|R+0#0000001#ffff4012|i|g|h|t| |t|e|x|t| 
|w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.
+| +0#af5f00255#ffffff0@3| +0#0000000&@35
+| +0#af5f00255&@3|B+0#0000001#ffff4012|e|l|o|w| +0#0000000#ffffff0@30
+| +0#af5f00255&@3|A+0#0000001#ffff4012|b|o|v|e| +0#0000000#ffffff0@30
+| +0#af5f00255&@1|3| |T+0#0000000&|h|i|r|d| |l|i|n|e| |f|i|t|s| |o|n| 
|s|c|r|e@1|n| |l|i|n|e|.|A+0#0000001#ffff4012|f|t|e|r
+| +0#af5f00255#ffffff0@3| +0#0000001#ffff4012|t|e|x|t| |w|r|a|p|s| |t|o| 
|n|e|x|t| |l|i|n|e|.| +0#0000000#ffffff0@10
+| +0#af5f00255&@3| +0#0000000&@5|R+0#0000001#ffff4012|i|g|h|t| |t|e|x|t| 
|w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.
+| +0#af5f00255#ffffff0@3|B+0#0000001#ffff4012|e|l|o|w| +0#0000000#ffffff0@30
+@22|1|,|1|6|-|5|2| @6|A|l@1| 
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index a7057147d..63cc53369 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -2690,7 +2690,7 @@ func Test_prop_inserts_text_normal_gj_gk()
   call Run_test_prop_inserts_text_normal_gj_gk('set virtualedit=all')
 endfunc
 
-func Test_prop_normal_gj_gk_over_outer_virtual_text()
+func Test_prop_normal_gj_gk_gM_with_outer_virtual_text()
   CheckRunVimInTerminal
 
   let lines =<< trim END
@@ -2708,23 +2708,26 @@ func Test_prop_normal_gj_gk_over_outer_virtual_text()
       endfor
       normal 3l
   END
-  call writefile(lines, 'XscriptPropsNormal_gj_gk_over_outer', 'D')
-  let buf = RunVimInTerminal('-S XscriptPropsNormal_gj_gk_over_outer', #{rows: 
16, cols: 40})
-  call VerifyScreenDump(buf, 
'Test_prop_normal_gj_gk_over_outer_virtual_text_1', {})
+  call writefile(lines, 'XscriptPropsNormal_gj_gk_gM_with_outer_text', 'D')
+  let buf = RunVimInTerminal('-S XscriptPropsNormal_gj_gk_gM_with_outer_text', 
#{rows: 16, cols: 40})
+  call VerifyScreenDump(buf, 
'Test_prop_normal_gj_gk_gM_with_outer_virtual_text_1', {})
 
   call term_sendkeys(buf, "gj")
-  call VerifyScreenDump(buf, 
'Test_prop_normal_gj_gk_over_outer_virtual_text_2', {})
+  call VerifyScreenDump(buf, 
'Test_prop_normal_gj_gk_gM_with_outer_virtual_text_2', {})
   call term_sendkeys(buf, "gj")
-  call VerifyScreenDump(buf, 
'Test_prop_normal_gj_gk_over_outer_virtual_text_3', {})
+  call VerifyScreenDump(buf, 
'Test_prop_normal_gj_gk_gM_with_outer_virtual_text_3', {})
   call term_sendkeys(buf, "gk")
-  call VerifyScreenDump(buf, 
'Test_prop_normal_gj_gk_over_outer_virtual_text_2', {})
+  call VerifyScreenDump(buf, 
'Test_prop_normal_gj_gk_gM_with_outer_virtual_text_2', {})
   call term_sendkeys(buf, "gk")
-  call VerifyScreenDump(buf, 
'Test_prop_normal_gj_gk_over_outer_virtual_text_1', {})
+  call VerifyScreenDump(buf, 
'Test_prop_normal_gj_gk_gM_with_outer_virtual_text_1', {})
 
   call term_sendkeys(buf, "2gj")
-  call VerifyScreenDump(buf, 
'Test_prop_normal_gj_gk_over_outer_virtual_text_3', {})
+  call VerifyScreenDump(buf, 
'Test_prop_normal_gj_gk_gM_with_outer_virtual_text_3', {})
   call term_sendkeys(buf, "2gk")
-  call VerifyScreenDump(buf, 
'Test_prop_normal_gj_gk_over_outer_virtual_text_1', {})
+  call VerifyScreenDump(buf, 
'Test_prop_normal_gj_gk_gM_with_outer_virtual_text_1', {})
+
+  call term_sendkeys(buf, "gM")
+  call VerifyScreenDump(buf, 
'Test_prop_normal_gj_gk_gM_with_outer_virtual_text_4', {})
 
   call StopVimInTerminal(buf)
 endfunc
diff --git a/src/version.c b/src/version.c
index 0e5e399a8..b38b235a1 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 */
+/**/
+    201,
 /**/
     200,
 /**/

-- 
-- 
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/E1roJi3-002r8z-Ld%40256bit.org.

Raspunde prin e-mail lui