diff options
Diffstat (limited to 'src/charset.c')
-rw-r--r-- | src/charset.c | 51 |
1 files changed, 14 insertions, 37 deletions
diff --git a/src/charset.c b/src/charset.c index d26a696c74..acf60999db 100644 --- a/src/charset.c +++ b/src/charset.c @@ -1069,40 +1069,6 @@ lbr_chartabsize_adv(chartabsize_T *cts) return retval; } -#if defined(FEAT_PROP_POPUP) || defined(PROTO) -/* - * Return the cell size of virtual text after truncation. - */ - int -textprop_size_after_trunc( - win_T *wp, - int below, - int added, - char_u *text, - int *n_used_ptr) -{ - int space = below ? wp->w_width : added; - int len = (int)STRLEN(text); - int strsize = 0; - int n_used; - - // if the remaining size is to small wrap - // anyway and use the next line - if (space < PROP_TEXT_MIN_CELLS) - space += wp->w_width; - for (n_used = 0; n_used < len; n_used += (*mb_ptr2len)(text + n_used)) - { - int clen = ptr2cells(text + n_used); - - if (strsize + clen > space) - break; - strsize += clen; - } - *n_used_ptr = n_used; - return strsize; -} -#endif - /* * Return the screen size of the character indicated by "cts". * "cts->cts_cur_text_width" is set to the extra size for a text property that @@ -1142,6 +1108,7 @@ win_lbr_chartabsize( #if defined(FEAT_PROP_POPUP) cts->cts_cur_text_width = 0; + cts->cts_first_char = 0; #endif #if defined(FEAT_LINEBREAK) || defined(FEAT_PROP_POPUP) @@ -1194,9 +1161,12 @@ win_lbr_chartabsize( if (tp->tp_id < 0 && ((tp->tp_col - 1 >= col && tp->tp_col - 1 < col + charlen) - || (tp->tp_col == MAXCOL && (s[0] == NUL || s[1] == NUL) - && cts->cts_with_trailing)) - && -tp->tp_id - 1 < gap->ga_len) + || (tp->tp_col == MAXCOL + && ((tp->tp_flags & TP_FLAG_ALIGN_ABOVE) + ? col == 0 + : (s[0] == NUL || s[1] == NUL) + && cts->cts_with_trailing))) + && tp->tp_id - 1 < gap->ga_len) { char_u *p = ((char_u **)gap->ga_data)[-tp->tp_id - 1]; @@ -1218,6 +1188,8 @@ win_lbr_chartabsize( else cells = vim_strsize(p); cts->cts_cur_text_width += cells; + if (tp->tp_flags & TP_FLAG_ALIGN_ABOVE) + cts->cts_first_char += cells; cts->cts_start_incl = tp->tp_flags & TP_FLAG_START_INCL; size += cells; if (*s == TAB) @@ -1564,6 +1536,11 @@ getvcol( #endif break; } +#ifdef FEAT_PROP_POPUP + if (cursor == &wp->w_virtcol && cts.cts_ptr == cts.cts_line) + // do not count the virtual text above for w_curswant + wp->w_virtcol_first_char = cts.cts_first_char; +#endif if (posptr != NULL && cts.cts_ptr >= posptr) // character at pos->col |