0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

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>
This commit is contained in:
zeertzjq
2024-01-25 21:27:13 +01:00
committed by Christian Brabandt
parent 12b9277672
commit 703f9bc943
3 changed files with 13 additions and 13 deletions

View File

@@ -1126,7 +1126,6 @@ win_lbr_chartabsize(
int n; int n;
char_u *sbr; char_u *sbr;
int no_sbr = FALSE; int no_sbr = FALSE;
colnr_T vcol_start = 0; // start from where to consider linebreak
#endif #endif
#if defined(FEAT_PROP_POPUP) #if defined(FEAT_PROP_POPUP)
@@ -1352,22 +1351,21 @@ win_lbr_chartabsize(
if (headp != NULL) if (headp != NULL)
*headp = head; *headp = head;
int need_lbr = FALSE;
/* /*
* If 'linebreak' set check at a blank before a non-blank if the line * 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; char_u *t = cts->cts_line;
while (VIM_ISBREAK((int)t[0])) while (VIM_ISBREAK((int)t[0]))
t++; 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 if (need_lbr)
&& VIM_ISBREAK((int)s[0])
&& !VIM_ISBREAK((int)s[1])
&& wp->w_p_wrap
&& wp->w_width != 0)
{ {
/* /*
* Count all characters from first non-blank after a blank up to next * Count all characters from first non-blank after a blank up to next

View File

@@ -374,13 +374,13 @@ endfunc
func Test_linebreak_no_break_after_whitespace_only() func Test_linebreak_no_break_after_whitespace_only()
call s:test_windows('setl ts=4 linebreak wrap') call s:test_windows('setl ts=4 linebreak wrap')
call setline(1, "\tabcdefghijklmnopqrstuvwxyz" .. call setline(1, "\t abcdefghijklmnopqrstuvwxyz" ..
\ "abcdefghijklmnopqrstuvwxyz") \ "abcdefghijklmnopqrstuvwxyz")
let lines = s:screen_lines([1, 4], winwidth(0)) let lines = s:screen_lines([1, 4], winwidth(0))
let expect = [ let expect = [
\ " abcdefghijklmnop", \ " abcdefghijklmn",
\ "qrstuvwxyzabcdefghij", \ "opqrstuvwxyzabcdefgh",
\ "klmnopqrstuvwxyz ", \ "ijklmnopqrstuvwxyz ",
\ "~ ", \ "~ ",
\ ] \ ]
call s:compare_lines(expect, lines) call s:compare_lines(expect, lines)

View File

@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
54,
/**/ /**/
53, 53,
/**/ /**/