diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-01-25 21:27:13 +0100 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-01-25 21:28:56 +0100 |
commit | 703f9bc943a29d947869b5cb0370be2ac42d5ac9 (patch) | |
tree | 4821305ec53b33271ab0cdc10cdcf79501bb95cb /src/charset.c | |
parent | 12b927767213502469284bc133f69b4d0da776cb (diff) |
patch 9.1.0054: 'linebreak' may still apply to leading whitespacev9.1.0054
Problem: 'linebreak' may still apply to leading whitespace
(VanaIgr)
Solution: Compare pointers instead of virtual columns.
(zeertzjq)
related: neovim/neovim#27180
closes: #13915
Co-authored-by: VanaIgr <vanaigranov@gmail.com>
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/charset.c')
-rw-r--r-- | src/charset.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/charset.c b/src/charset.c index eef2e8983c..919885df07 100644 --- a/src/charset.c +++ b/src/charset.c @@ -1126,7 +1126,6 @@ win_lbr_chartabsize( int n; char_u *sbr; int no_sbr = FALSE; - colnr_T vcol_start = 0; // start from where to consider linebreak #endif #if defined(FEAT_PROP_POPUP) @@ -1352,22 +1351,21 @@ win_lbr_chartabsize( if (headp != NULL) *headp = head; + int need_lbr = FALSE; /* * If 'linebreak' set check at a blank before a non-blank if the line - * needs a break here + * needs a break here. */ - if (wp->w_p_lbr && wp->w_p_wrap && wp->w_width != 0) + if (wp->w_p_lbr && wp->w_p_wrap && wp->w_width != 0 + && VIM_ISBREAK((int)s[0]) && !VIM_ISBREAK((int)s[1])) { char_u *t = cts->cts_line; while (VIM_ISBREAK((int)t[0])) t++; - vcol_start = t - cts->cts_line; + // 'linebreak' is only needed when not in leading whitespace. + need_lbr = s >= t; } - if (wp->w_p_lbr && vcol_start <= vcol - && VIM_ISBREAK((int)s[0]) - && !VIM_ISBREAK((int)s[1]) - && wp->w_p_wrap - && wp->w_width != 0) + if (need_lbr) { /* * Count all characters from first non-blank after a blank up to next |