summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-27 11:17:39 +0200
committerChristian Brabandt <cb@256bit.org>2023-08-27 11:17:39 +0200
commitd809c0a90387a23aed21ba37d0b65332fb5dafe7 (patch)
tree2d1e407ab6d503b26fdd1adce5a3b86a4e5c7156
parent58f39d89a8adff51ab04893d1fd28e3767979f9f (diff)
patch 9.0.1792: problem with gj/gk/gM and virtual textv9.0.1792
Problem: Normal mode "gM", "gj", "gk" commands behave incorrectly with virtual text. Solution: Use linetabsize() instead of linetabsize_str(). closes: #12909 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
-rw-r--r--src/misc2.c4
-rw-r--r--src/normal.c8
-rw-r--r--src/testdir/dumps/Test_prop_inserts_text_normal_gM.dump3
-rw-r--r--src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_1.dump6
-rw-r--r--src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_2.dump6
-rw-r--r--src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_3.dump6
-rw-r--r--src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_4.dump6
-rw-r--r--src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_5.dump6
-rw-r--r--src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_6.dump6
-rw-r--r--src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_7.dump6
-rw-r--r--src/testdir/test_textprop.vim51
-rw-r--r--src/version.c4
12 files changed, 106 insertions, 6 deletions
diff --git a/src/misc2.c b/src/misc2.c
index 458e62b267..169eb5197c 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -150,7 +150,7 @@ coladvance2(
if ((addspaces || finetune) && !VIsual_active)
{
- curwin->w_curswant = linetabsize_str(line) + one_more;
+ curwin->w_curswant = linetabsize(curwin, pos->lnum) + one_more;
if (curwin->w_curswant > 0)
--curwin->w_curswant;
}
@@ -166,7 +166,7 @@ coladvance2(
&& wcol >= (colnr_T)width
&& width > 0)
{
- csize = linetabsize_str(line);
+ csize = linetabsize(curwin, pos->lnum);
if (csize > 0)
csize--;
diff --git a/src/normal.c b/src/normal.c
index 38229e96e5..b73afd3212 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -2304,7 +2304,7 @@ find_decl(
static int
nv_screengo(oparg_T *oap, int dir, long dist)
{
- int linelen = linetabsize_str(ml_get_curline());
+ int linelen = linetabsize(curwin, curwin->w_cursor.lnum);
int retval = OK;
int atend = FALSE;
int n;
@@ -2374,7 +2374,7 @@ nv_screengo(oparg_T *oap, int dir, long dist)
}
cursor_up_inner(curwin, 1);
- linelen = linetabsize_str(ml_get_curline());
+ linelen = linetabsize(curwin, curwin->w_cursor.lnum);
if (linelen > width1)
curwin->w_curswant += (((linelen - width1 - 1) / width2)
+ 1) * width2;
@@ -2411,7 +2411,7 @@ nv_screengo(oparg_T *oap, int dir, long dist)
// clipped to column 0.
if (curwin->w_curswant >= width1)
curwin->w_curswant -= width2;
- linelen = linetabsize_str(ml_get_curline());
+ linelen = linetabsize(curwin, curwin->w_cursor.lnum);
}
}
}
@@ -6052,7 +6052,7 @@ nv_g_cmd(cmdarg_T *cap)
{
oap->motion_type = MCHAR;
oap->inclusive = FALSE;
- i = linetabsize_str(ml_get_curline());
+ i = linetabsize(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_inserts_text_normal_gM.dump b/src/testdir/dumps/Test_prop_inserts_text_normal_gM.dump
new file mode 100644
index 0000000000..dbefdf5415
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_inserts_text_normal_gM.dump
@@ -0,0 +1,3 @@
+|1+0&#ffffff0|2|b+0#e000e06&@2|3+0#0000000&|4>5|6|7|b+0#e000e06&@2|8+0#0000000&|9| @44
+|~+0#4040ff13&| @58
+| +0#0000000&@41|1|,|5|-|8| @8|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_1.dump b/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_1.dump
new file mode 100644
index 0000000000..74595ac762
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_1.dump
@@ -0,0 +1,6 @@
+>a+0&#ffffff0@39|b@9|a@9
+@5| @54
+|a@39|b@9|a@9
+@5| @54
+|~+0#4040ff13&| @58
+| +0#0000000&@41|1|,|1| @10|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_2.dump b/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_2.dump
new file mode 100644
index 0000000000..18507a7854
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_2.dump
@@ -0,0 +1,6 @@
+|a+0&#ffffff0@39|b@9|a@9
+>a@4| @54
+|a@39|b@9|a@9
+@5| @54
+|~+0#4040ff13&| @58
+| +0#0000000&@41|1|,|5|1|-|6|1| @6|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_3.dump b/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_3.dump
new file mode 100644
index 0000000000..8520059c08
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_3.dump
@@ -0,0 +1,6 @@
+|a+0&#ffffff0@39|b@9|a@9
+@5| @54
+>a@39|b@9|a@9
+@5| @54
+|~+0#4040ff13&| @58
+| +0#0000000&@41|2|,|1| @10|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_4.dump b/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_4.dump
new file mode 100644
index 0000000000..f0073f6bdd
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_4.dump
@@ -0,0 +1,6 @@
+|a+0&#ffffff0@39|b@9|a@9
+@5| @54
+|a@39|b@9|a@9
+>a@4| @54
+|~+0#4040ff13&| @58
+| +0#0000000&@41|2|,|5|1|-|6|1| @6|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_5.dump b/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_5.dump
new file mode 100644
index 0000000000..8520059c08
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_5.dump
@@ -0,0 +1,6 @@
+|a+0&#ffffff0@39|b@9|a@9
+@5| @54
+>a@39|b@9|a@9
+@5| @54
+|~+0#4040ff13&| @58
+| +0#0000000&@41|2|,|1| @10|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_6.dump b/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_6.dump
new file mode 100644
index 0000000000..18507a7854
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_6.dump
@@ -0,0 +1,6 @@
+|a+0&#ffffff0@39|b@9|a@9
+>a@4| @54
+|a@39|b@9|a@9
+@5| @54
+|~+0#4040ff13&| @58
+| +0#0000000&@41|1|,|5|1|-|6|1| @6|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_7.dump b/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_7.dump
new file mode 100644
index 0000000000..74595ac762
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_inserts_text_normal_gj_gk_7.dump
@@ -0,0 +1,6 @@
+>a+0&#ffffff0@39|b@9|a@9
+@5| @54
+|a@39|b@9|a@9
+@5| @54
+|~+0#4040ff13&| @58
+| +0#0000000&@41|1|,|1| @10|A|l@1|
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index 05bba61644..93baa7a7ed 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -2602,6 +2602,57 @@ func Test_prop_inserts_text_highlight()
call StopVimInTerminal(buf)
endfunc
+func Test_prop_inserts_text_normal_gM()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ call setline(1, '123456789')
+ call prop_type_add('theprop', #{highlight: 'Special'})
+ call prop_add(1, 3, {'type': 'theprop', 'text': 'bbb'})
+ call prop_add(1, 8, {'type': 'theprop', 'text': 'bbb'})
+ END
+ call writefile(lines, 'XscriptPropsNormal_gM', 'D')
+ let buf = RunVimInTerminal('-S XscriptPropsNormal_gM', #{rows: 3, cols: 60})
+ call term_sendkeys(buf, "gM")
+ call VerifyScreenDump(buf, 'Test_prop_inserts_text_normal_gM', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
+func Run_test_prop_inserts_text_normal_gj_gk(cmd)
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ call setline(1, repeat([repeat('a', 55)], 2))
+ call prop_type_add('theprop', {})
+ call prop_add(1, 41, {'type': 'theprop', 'text': repeat('b', 10)})
+ call prop_add(2, 41, {'type': 'theprop', 'text': repeat('b', 10)})
+ END
+ let lines = insert(lines, a:cmd)
+ call writefile(lines, 'XscriptPropsNormal_gj_gk', 'D')
+ let buf = RunVimInTerminal('-S XscriptPropsNormal_gj_gk', #{rows: 6, cols: 60})
+ call VerifyScreenDump(buf, 'Test_prop_inserts_text_normal_gj_gk_1', {})
+ call term_sendkeys(buf, "gj")
+ call VerifyScreenDump(buf, 'Test_prop_inserts_text_normal_gj_gk_2', {})
+ call term_sendkeys(buf, "gj")
+ call VerifyScreenDump(buf, 'Test_prop_inserts_text_normal_gj_gk_3', {})
+ call term_sendkeys(buf, "gj")
+ call VerifyScreenDump(buf, 'Test_prop_inserts_text_normal_gj_gk_4', {})
+ call term_sendkeys(buf, "gk")
+ call VerifyScreenDump(buf, 'Test_prop_inserts_text_normal_gj_gk_5', {})
+ call term_sendkeys(buf, "gk")
+ call VerifyScreenDump(buf, 'Test_prop_inserts_text_normal_gj_gk_6', {})
+ call term_sendkeys(buf, "gk")
+ call VerifyScreenDump(buf, 'Test_prop_inserts_text_normal_gj_gk_7', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_prop_inserts_text_normal_gj_gk()
+ call Run_test_prop_inserts_text_normal_gj_gk('')
+ call Run_test_prop_inserts_text_normal_gj_gk('set virtualedit=all')
+endfunc
+
func Test_prop_inserts_text_visual_block()
CheckRunVimInTerminal
diff --git a/src/version.c b/src/version.c
index 9e4e742341..6d6685d8ca 100644
--- a/src/version.c
+++ b/src/version.c
@@ -700,6 +700,10 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1792,
+/**/
+ 1791,
+/**/
1790,
/**/
1789,