Mercurial > vim
comparison src/charset.c @ 34211:f9b706e23b10 v9.1.0054
patch 9.1.0054: 'linebreak' may still apply to leading whitespace
Commit: https://github.com/vim/vim/commit/703f9bc943a29d947869b5cb0370be2ac42d5ac9
Author: zeertzjq <zeertzjq@outlook.com>
Date: Thu Jan 25 21:27:13 2024 +0100
patch 9.1.0054: 'linebreak' may still apply to leading whitespace
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>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 25 Jan 2024 21:45:02 +0100 |
parents | 5c42c39dab38 |
children | 84a5cafeb34c |
comparison
equal
deleted
inserted
replaced
34210:c12a674080bc | 34211:f9b706e23b10 |
---|---|
1124 int size; | 1124 int size; |
1125 int mb_added = 0; | 1125 int mb_added = 0; |
1126 int n; | 1126 int n; |
1127 char_u *sbr; | 1127 char_u *sbr; |
1128 int no_sbr = FALSE; | 1128 int no_sbr = FALSE; |
1129 colnr_T vcol_start = 0; // start from where to consider linebreak | |
1130 #endif | 1129 #endif |
1131 | 1130 |
1132 #if defined(FEAT_PROP_POPUP) | 1131 #if defined(FEAT_PROP_POPUP) |
1133 cts->cts_cur_text_width = 0; | 1132 cts->cts_cur_text_width = 0; |
1134 cts->cts_first_char = 0; | 1133 cts->cts_first_char = 0; |
1350 } | 1349 } |
1351 | 1350 |
1352 if (headp != NULL) | 1351 if (headp != NULL) |
1353 *headp = head; | 1352 *headp = head; |
1354 | 1353 |
1354 int need_lbr = FALSE; | |
1355 /* | 1355 /* |
1356 * If 'linebreak' set check at a blank before a non-blank if the line | 1356 * If 'linebreak' set check at a blank before a non-blank if the line |
1357 * needs a break here | 1357 * needs a break here. |
1358 */ | 1358 */ |
1359 if (wp->w_p_lbr && wp->w_p_wrap && wp->w_width != 0) | 1359 if (wp->w_p_lbr && wp->w_p_wrap && wp->w_width != 0 |
1360 && VIM_ISBREAK((int)s[0]) && !VIM_ISBREAK((int)s[1])) | |
1360 { | 1361 { |
1361 char_u *t = cts->cts_line; | 1362 char_u *t = cts->cts_line; |
1362 while (VIM_ISBREAK((int)t[0])) | 1363 while (VIM_ISBREAK((int)t[0])) |
1363 t++; | 1364 t++; |
1364 vcol_start = t - cts->cts_line; | 1365 // 'linebreak' is only needed when not in leading whitespace. |
1365 } | 1366 need_lbr = s >= t; |
1366 if (wp->w_p_lbr && vcol_start <= vcol | 1367 } |
1367 && VIM_ISBREAK((int)s[0]) | 1368 if (need_lbr) |
1368 && !VIM_ISBREAK((int)s[1]) | |
1369 && wp->w_p_wrap | |
1370 && wp->w_width != 0) | |
1371 { | 1369 { |
1372 /* | 1370 /* |
1373 * Count all characters from first non-blank after a blank up to next | 1371 * Count all characters from first non-blank after a blank up to next |
1374 * non-blank after a blank. | 1372 * non-blank after a blank. |
1375 */ | 1373 */ |