patch 9.0.2187: Visual not drawn with 'breakindent' when line doesn't fit

Commit: 
https://github.com/vim/vim/commit/23627722d36b49e38ba6f8dc6bb3ebe19c98a83b
Author: zeertzjq <[email protected]>
Date:   Wed Dec 27 19:08:53 2023 +0100

    patch 9.0.2187: Visual not drawn with 'breakindent' when line doesn't fit
    
    Problem:  Visual selection isn't drawn with 'breakindent' when the line
              doesn't fit in the window (Jaehwang Jung)
    Solution: Adjust wlv->fromcol also for 'breakindent' (zeertzjq)
    
    closes: #13767
    closes: #13768
    
    Signed-off-by: zeertzjq <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/drawline.c b/src/drawline.c
index 9f385f033..08b6f45c4 100644
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -527,6 +527,12 @@ handle_breakindent(win_T *wp, winlinevars_T *wlv)
            if (wp->w_skipcol > 0 && wlv->startrow == 0
                                           && wp->w_p_wrap && wp->w_briopt_sbr)
                wlv->need_showbreak = FALSE;
+
+           // Correct start of highlighted area for 'breakindent',
+           if (wlv->fromcol >= wlv->vcol
+                                   && wlv->fromcol < wlv->vcol + wlv->n_extra)
+               wlv->fromcol = wlv->vcol + wlv->n_extra;
+
            // Correct end of highlighted area for 'breakindent',
            // required when 'linebreak' is also set.
            if (wlv->tocol == wlv->vcol)
diff --git a/src/testdir/dumps/Test_visual_starts_before_skipcol_1.dump 
b/src/testdir/dumps/Test_visual_starts_before_skipcol_1.dump
new file mode 100644
index 000000000..f61440ad3
--- /dev/null
+++ b/src/testdir/dumps/Test_visual_starts_before_skipcol_1.dump
@@ -0,0 +1,6 @@
+|<+0#4040ff13#ffffff0@2| +0#0000000&@4| +0&#e0e0e08|9|3| |9|4| |9|5| |9|6| 
|9|7| |9|8| |9@1> +0&#ffffff0@45
+|[+3&&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|2|9|1|-|3@1|0| @5|A|l@1
+| +0&&@74
+|~+0#4040ff13&| @73
+|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1
+|-+2&&@1| |V|I|S|U|A|L| |-@1| +0&&@51|2|9|1| @7
diff --git a/src/testdir/dumps/Test_visual_starts_before_skipcol_2.dump 
b/src/testdir/dumps/Test_visual_starts_before_skipcol_2.dump
new file mode 100644
index 000000000..1f1094058
--- /dev/null
+++ b/src/testdir/dumps/Test_visual_starts_before_skipcol_2.dump
@@ -0,0 +1,6 @@
+| +0&#ffffff0@7|++0#4040ff13&@2| +0#0000000#e0e0e08|9|0| |9|1| |9|2| |9|3| 
|9|4| |9|5| |9|6| |9|7| |9|8| |9@1> +0&#ffffff0@33
+|[+3&&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|2|9|1|-|3|4|2| @5|A|l@1
+| +0&&@74
+|~+0#4040ff13&| @73
+|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1
+|-+2&&@1| |V|I|S|U|A|L| |-@1| +0&&@51|2|9|1| @7
diff --git a/src/testdir/dumps/Test_visual_starts_before_skipcol_3.dump 
b/src/testdir/dumps/Test_visual_starts_before_skipcol_3.dump
new file mode 100644
index 000000000..d36d6752e
--- /dev/null
+++ b/src/testdir/dumps/Test_visual_starts_before_skipcol_3.dump
@@ -0,0 +1,6 @@
+|++0#4040ff13#ffffff0@2| +0#0000000&@4| +0&#e0e0e08|9|3| |9|4| |9|5| |9|6| 
|9|7| |9|8| |9@1> +0&#ffffff0@45
+|[+3&&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|2|9|1|-|3@1|0| @5|A|l@1
+| +0&&@74
+|~+0#4040ff13&| @73
+|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1
+|-+2&&@1| |V|I|S|U|A|L| |-@1| +0&&@51|2|9|1| @7
diff --git a/src/testdir/dumps/Test_visual_starts_before_skipcol_4.dump 
b/src/testdir/dumps/Test_visual_starts_before_skipcol_4.dump
new file mode 100644
index 000000000..246040717
--- /dev/null
+++ b/src/testdir/dumps/Test_visual_starts_before_skipcol_4.dump
@@ -0,0 +1,6 @@
+|++0#4040ff13#ffffff0@8>+@65
+|[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|2|9|1|-|3|1|0| @5|A|l@1
+| +0&&@74
+|~+0#4040ff13&| @73
+|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1
+|-+2&&@1| |V|I|S|U|A|L| |-@1| +0&&@51|2|9|1| @7
diff --git a/src/testdir/test_breakindent.vim b/src/testdir/test_breakindent.vim
index 3c4d0f1d0..ee0554822 100644
--- a/src/testdir/test_breakindent.vim
+++ b/src/testdir/test_breakindent.vim
@@ -923,6 +923,29 @@ func Test_cursor_position_with_showbreak()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_visual_starts_before_skipcol()
+  CheckScreendump
+
+  let lines =<< trim END
+    1new
+    setlocal breakindent
+    call setline(1, "  " .. join(range(100)))
+  END
+  call writefile(lines, 'XvisualStartsBeforeSkipcol', 'D')
+  let buf = RunVimInTerminal('-S XvisualStartsBeforeSkipcol', #{rows: 6})
+
+  call term_sendkeys(buf, "v$")
+  call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_1', {})
+  call term_sendkeys(buf, "\<Esc>:setlocal showbreak=+++\<CR>gv")
+  call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_2', {})
+  call term_sendkeys(buf, "\<Esc>:setlocal breakindentopt+=sbr\<CR>gv")
+  call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_3', {})
+  call term_sendkeys(buf, "\<Esc>:setlocal nobreakindent\<CR>gv")
+  call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_4', {})
+
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_no_spurious_match()
   let s:input = printf('- y %s y %s', repeat('x', 50), repeat('x', 50))
   call s:test_windows('setl breakindent breakindentopt=list:-1 
formatlistpat=^- hls')
diff --git a/src/version.c b/src/version.c
index 5446a5264..f7dc49bfe 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 */
+/**/
+    2187,
 /**/
     2186,
 /**/

-- 
-- 
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/E1rIYQt-00GpPr-VR%40256bit.org.

Raspunde prin e-mail lui