summaryrefslogtreecommitdiffstats
path: root/src/charset.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-08-13 16:41:19 +0100
committerBram Moolenaar <Bram@vim.org>2022-08-13 16:41:19 +0100
commitf0ccfa474a5c4940d03bfc6084e896dc8ac2d791 (patch)
tree2dff4269a2a70e50568d66e3631c47975beb4053 /src/charset.c
parentcfeb8a584be11758cf71ae02f6c937b06d6bb66f (diff)
patch 9.0.0199: cursor position wrong with two right-aligned virtual textsv9.0.0199
Problem: Cursor position wrong with two right-aligned virtual texts. Solution: Add the padding for right-alignment. (issue #10906)
Diffstat (limited to 'src/charset.c')
-rw-r--r--src/charset.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/charset.c b/src/charset.c
index 2975cdb194..a795984068 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1181,6 +1181,7 @@ win_lbr_chartabsize(
if (tp->tp_col == MAXCOL)
{
int below = (tp->tp_flags & TP_FLAG_ALIGN_BELOW);
+ int right = (tp->tp_flags & TP_FLAG_ALIGN_RIGHT);
int wrap = (tp->tp_flags & TP_FLAG_WRAP);
int len = (int)STRLEN(p);
int n_used = len;
@@ -1193,10 +1194,19 @@ win_lbr_chartabsize(
cells = textprop_size_after_trunc(wp,
below, added, p, &n_used);
}
- // right-aligned does not really matter here, same as
- // "after"
if (below)
cells += wp->w_width - (vcol + size) % wp->w_width;
+ else if (right)
+ {
+ len = wp->w_width - vcol % wp->w_width;
+ if (len > cells + size)
+ // add the padding for right-alignment
+ cells = len - size;
+ else if (len == 0)
+ // padding to right-align in the next line
+ cells += cells > wp->w_width ? 0
+ :wp->w_width - cells;
+ }
#ifdef FEAT_LINEBREAK
no_sbr = TRUE; // don't use 'showbreak' now
#endif