]> granicus.if.org Git - vim/commitdiff
patch 9.0.0357: 'linebreak' interferes with text property highlight v9.0.0357
authorBram Moolenaar <Bram@vim.org>
Fri, 2 Sep 2022 12:26:29 +0000 (13:26 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 2 Sep 2022 12:26:29 +0000 (13:26 +0100)
Problem:    'linebreak' interferes with text property highlight if there is
            syntax highlighting.
Solution:   Check the text prop attributes after combining with syntax
            attributes. (closes #11035)

src/drawline.c
src/testdir/dumps/Test_prop_linebreak_1.dump [moved from src/testdir/dumps/Test_prop_linebreak.dump with 65% similarity]
src/testdir/dumps/Test_prop_linebreak_2.dump [new file with mode: 0644]
src/testdir/test_textprop.vim
src/version.c

index 26886bd9455e170a14bc5188084f519b83ad22a7..6c298b6f481562ceea8febe8eb1a47854147839e 100644 (file)
@@ -612,6 +612,8 @@ win_line(
     proptype_T  *text_prop_type = NULL;
     int                extra_for_textprop = FALSE; // wlv.n_extra set for textprop
     int                text_prop_attr = 0;
+    int                text_prop_attr_comb = 0;  // text_prop_attr combined with
+                                         // syntax_attr
     int                text_prop_id = 0;       // active property ID
     int                text_prop_flags = 0;
     int                text_prop_follows = FALSE;  // another text prop to display
@@ -1676,7 +1678,7 @@ win_line(
                        --pi;
 # ifdef FEAT_LINEBREAK
                        // not exactly right but should work in most cases
-                       if (in_linebreak && syntax_attr == text_prop_attr)
+                       if (in_linebreak && syntax_attr == text_prop_attr_comb)
                            syntax_attr = 0;
 # endif
                    }
@@ -1716,6 +1718,7 @@ win_line(
                if (wlv.n_extra == 0 || !extra_for_textprop)
                {
                    text_prop_attr = 0;
+                   text_prop_attr_comb = 0;
                    text_prop_flags = 0;
                    text_prop_type = NULL;
                    text_prop_id = 0;
@@ -1789,6 +1792,7 @@ win_line(
                            saved_search_attr = search_attr;
                            search_attr = 0;    // restore when n_extra is zero
                            text_prop_attr = 0;
+                           text_prop_attr_comb = 0;
                            if (*ptr == NUL)
                                // don't combine char attr after EOL
                                text_prop_flags &= ~PT_FLAG_COMBINE;
@@ -1974,6 +1978,7 @@ win_line(
                    syntax_attr = hl_combine_attr(syntax_attr, text_prop_attr);
                else
                    syntax_attr = text_prop_attr;
+               text_prop_attr_comb = syntax_attr;
            }
 # endif
 #endif
similarity index 65%
rename from src/testdir/dumps/Test_prop_linebreak.dump
rename to src/testdir/dumps/Test_prop_linebreak_1.dump
index 33be5b3122a6011e2bbfc62a0b226f850911f568..c1a56e85e7148cfca745b548935a35a7c9865f4d 100644 (file)
@@ -1,4 +1,4 @@
->x+0&#ffffff0@49|]+0#ffffff16#e000002| +0#0000000#ffffff0@23
+>x+0&#ffffff0@49|]+0&#40ffff15| +0&#ffffff0@23
 |x@69| @4
 |~+0#4040ff13&| @73
 |~| @73
diff --git a/src/testdir/dumps/Test_prop_linebreak_2.dump b/src/testdir/dumps/Test_prop_linebreak_2.dump
new file mode 100644 (file)
index 0000000..e705f71
--- /dev/null
@@ -0,0 +1,10 @@
+| +0#0000e05#a8a8a8255@1>x+0&#ffffff0@49|]+0&#40ffff15| +0#0000000#ffffff0@21
+| +0#0000e05#a8a8a8255@1|x+0&#ffffff0@69| +0#0000000&@2
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
index 03ae9c97e0a21cb4f0d6964266c40c556d25d3a4..21d751fb14fbbc56495ec2d015e23601d66593f1 100644 (file)
@@ -1925,12 +1925,21 @@ func Test_prop_in_linebreak()
   let lines =<< trim END
     set breakindent linebreak breakat+=]
     call printf('%s]%s', repeat('x', 50), repeat('x', 70))->setline(1)
-    call prop_type_add('test', #{highlight: 'ErrorMsg'})
+    call prop_type_add('test', #{highlight: 'MatchParen'})
     call prop_add(1, 51, #{length: 1, type: 'test'})
+    func AddMatch()
+      syntax on
+      syntax match xTest /.*/
+      hi link xTest Comment
+      set signcolumn=yes
+    endfunc
   END
   call writefile(lines, 'XscriptPropLinebreak')
   let buf = RunVimInTerminal('-S XscriptPropLinebreak', #{rows: 10})
-  call VerifyScreenDump(buf, 'Test_prop_linebreak', {})
+  call VerifyScreenDump(buf, 'Test_prop_linebreak_1', {})
+
+  call term_sendkeys(buf, ":call AddMatch()\<CR>")
+  call VerifyScreenDump(buf, 'Test_prop_linebreak_2', {})
 
   call StopVimInTerminal(buf)
   call delete('XscriptPropLinebreak')
index f017ba1d1ef294267f2e24e2f03775d9aef6ed8f..9d05dc30497c39182d80a3b8e42a43158025596f 100644 (file)
@@ -707,6 +707,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    357,
 /**/
     356,
 /**/