diff options
author | Bram Moolenaar <Bram@vim.org> | 2023-02-12 18:03:57 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-02-12 18:03:57 +0000 |
commit | 55a27d8ea7c112429fff14aba5db562de7f765f1 (patch) | |
tree | aeb299a91f93fa48d9e73dd1f7909e4de34de067 | |
parent | 234c3fab28c14846b962c90097496b27ee1b4df8 (diff) | |
download | vim-git-55a27d8ea7c112429fff14aba5db562de7f765f1.tar.gz |
patch 9.0.1305: cursor in wrong line with virtual text abovev9.0.1305
Problem: Cursor in wrong line with virtual text above.
Solution: Count extra line for text property above/below. (closes #11959)
-rw-r--r-- | src/charset.c | 9 | ||||
-rw-r--r-- | src/structs.h | 1 | ||||
-rw-r--r-- | src/testdir/dumps/Test_prop_above_empty_1.dump | 16 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 28 insertions, 0 deletions
diff --git a/src/charset.c b/src/charset.c index ebec2cf40..3ce95c7f4 100644 --- a/src/charset.c +++ b/src/charset.c @@ -813,6 +813,11 @@ win_linetabsize_cts(chartabsize_T *cts, colnr_T len) { (void)win_lbr_chartabsize(cts, NULL); cts->cts_vcol += cts->cts_cur_text_width; + + // when properties are above or below the empty line must also be + // counted + if (cts->cts_prop_lines > 0) + ++cts->cts_vcol; } #endif } @@ -1217,6 +1222,10 @@ win_lbr_chartabsize( tab_size = win_chartabsize(wp, s, vcol + size); size += tab_size; } + if (tp->tp_col == MAXCOL && (tp->tp_flags + & (TP_FLAG_ALIGN_ABOVE | TP_FLAG_ALIGN_BELOW))) + // count extra line for property above/below + ++cts->cts_prop_lines; } } if (tp->tp_col != MAXCOL && tp->tp_col - 1 > col) diff --git a/src/structs.h b/src/structs.h index 1c7a52788..a320d7069 100644 --- a/src/structs.h +++ b/src/structs.h @@ -4781,6 +4781,7 @@ typedef struct { textprop_T *cts_text_props; // text props (allocated) char cts_has_prop_with_text; // TRUE if if a property inserts text int cts_cur_text_width; // width of current inserted text + int cts_prop_lines; // nr of properties above or below int cts_first_char; // width text props above the line int cts_with_trailing; // include size of trailing props with // last character diff --git a/src/testdir/dumps/Test_prop_above_empty_1.dump b/src/testdir/dumps/Test_prop_above_empty_1.dump new file mode 100644 index 000000000..721d0c392 --- /dev/null +++ b/src/testdir/dumps/Test_prop_above_empty_1.dump @@ -0,0 +1,16 @@ +| +0#af5f00255#ffffff0@3|-+0#0000001#ffff4012@2| +0#0000000#ffffff0@52 +| +0#af5f00255&@1|1| |1+0#0000000&@7| @47 +| +0#af5f00255&@3|-+0#0000001#ffff4012@2| +0#0000000#ffffff0@52 +| +0#af5f00255&@1|2| | +0#0000000&@55 +| +0#af5f00255&@3|-+0#0000001#ffff4012@2| +0#0000000#ffffff0@52 +| +0#af5f00255&@1|3| |3+0#0000000&@8| @46 +| +0#af5f00255&@3|-+0#0000001#ffff4012@2| +0#0000000#ffffff0@52 +| +0#af5f00255&@1|4| | +0#0000000&@55 +| +0#af5f00255&@3|-+0#0000001#ffff4012@2| +0#0000000#ffffff0@52 +| +0#af5f00255&@1|5| >5+0#0000000&@10| @44 +|~+0#4040ff13&| @58 +|~| @58 +|~| @58 +|~| @58 +|~| @58 +| +0#0000000&@41|5|,|1|-|5|7| @7|A|l@1| diff --git a/src/version.c b/src/version.c index 26e8ab57c..a26fd5d2a 100644 --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1305, +/**/ 1304, /**/ 1303, |