summaryrefslogtreecommitdiff
path: root/src/textprop.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-08-13 19:35:05 +0100
committerBram Moolenaar <Bram@vim.org>2022-08-13 19:35:05 +0100
commit8f369fb1ab7debeeda0fec69c379c528d162d9c5 (patch)
tree8bac22fd9b0178208bc8365845f43380b6bb0856 /src/textprop.c
parentf0ccfa474a5c4940d03bfc6084e896dc8ac2d791 (diff)
downloadvim-git-8f369fb1ab7debeeda0fec69c379c528d162d9c5.tar.gz
patch 9.0.0200: cursor wrong if 'nowrap' and two right aligned text propsv9.0.0200
Problem: cursor in a wrong positoin if 'wrap' is off and using two right aligned text props in one line. Solution: Count an extra line for a right aligned text property after a below or right aligned text property. (issue #10909)
Diffstat (limited to 'src/textprop.c')
-rw-r--r--src/textprop.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/textprop.c b/src/textprop.c
index 7d594da16..88156c272 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -590,6 +590,8 @@ get_text_props(buf_T *buf, linenr_T lnum, char_u **props, int will_change)
/*
* Return the number of text properties with "below" alignment in line "lnum".
+ * A "right" aligned property also goes below after a "below" or other "right"
+ * aligned property.
*/
int
prop_count_below(buf_T *buf, linenr_T lnum)
@@ -599,14 +601,25 @@ prop_count_below(buf_T *buf, linenr_T lnum)
int result = 0;
textprop_T prop;
int i;
+ int next_right_goes_below = FALSE;
if (count == 0)
return 0;
for (i = 0; i < count; ++i)
{
mch_memmove(&prop, props + i * sizeof(prop), sizeof(prop));
- if (prop.tp_col == MAXCOL && (prop.tp_flags & TP_FLAG_ALIGN_BELOW))
- ++result;
+ if (prop.tp_col == MAXCOL)
+ {
+ if ((prop.tp_flags & TP_FLAG_ALIGN_BELOW)
+ || (next_right_goes_below
+ && (prop.tp_flags & TP_FLAG_ALIGN_RIGHT)))
+ {
+ next_right_goes_below = TRUE;
+ ++result;
+ }
+ else if (prop.tp_flags & TP_FLAG_ALIGN_RIGHT)
+ next_right_goes_below = TRUE;
+ }
}
return result;
}