patch 9.1.0054: 'linebreak' may still apply to leading whitespace

Commit: 
https://github.com/vim/vim/commit/703f9bc943a29d947869b5cb0370be2ac42d5ac9
Author: zeertzjq <[email protected]>
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 <[email protected]>
    Signed-off-by: zeertzjq <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/charset.c b/src/charset.c
index eef2e8983..919885df0 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
diff --git a/src/testdir/test_listlbr.vim b/src/testdir/test_listlbr.vim
index bcbd886ab..68bf94865 100644
--- a/src/testdir/test_listlbr.vim
+++ b/src/testdir/test_listlbr.vim
@@ -374,13 +374,13 @@ endfunc
 
 func Test_linebreak_no_break_after_whitespace_only()
   call s:test_windows('setl ts=4 linebreak wrap')
-  call setline(1, "    abcdefghijklmnopqrstuvwxyz" ..
+  call setline(1, "      abcdefghijklmnopqrstuvwxyz" ..
         \ "abcdefghijklmnopqrstuvwxyz")
   let lines = s:screen_lines([1, 4], winwidth(0))
   let expect = [
-\ "    abcdefghijklmnop",
-\ "qrstuvwxyzabcdefghij",
-\ "klmnopqrstuvwxyz    ",
+\ "      abcdefghijklmn",
+\ "opqrstuvwxyzabcdefgh",
+\ "ijklmnopqrstuvwxyz  ",
 \ "~                   ",
 \ ]
   call s:compare_lines(expect, lines)
diff --git a/src/version.c b/src/version.c
index a8dba0e78..fe10b9569 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    54,
 /**/
     53,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1rT6as-00CyFB-Vp%40256bit.org.

Raspunde prin e-mail lui