Re: Patch 8.2.2068

2020-11-29 Fir de Conversatie Charles Campbell

  
  
Bram Moolenaar wrote:


  
Patch 8.2.2068
Problem:Transparent syntax item uses start/end of containing region.
Solution:   Do not change the startpos and endpos of a transparent region to
that of its containing region. (Adrian Ghizaru, closes #7349,
closes #7391)
Files:  src/syntax.c, src/testdir/test_syntax.vim



I wish there were startcontains=grouplist and endcontains=grouplist
for start=pattern and end=pattern in syntax highlighting.

As an example, consider heredocs in shell syntax:

cat <
      shHereDoc01
      this is   (testing trailing fgrep
  on cat line)
      a
  
      junky
      test  (--endtest--)
          $lookitup
  EOF  

 To support folding properly, we need cat through EOF to be in one
region. However, that | fgrep ... should be highlighted as regular
shell syntax. Currently its not because I cannot do both folding of
the entire heredoc and the shell syntax embedded in the start
pattern for the region.

Regards,
Chip Campbell
  




-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/483cf29f-91c2-be60-e470-8b0dd79b846c%40drchip.org.


Patch 8.2.2068

2020-11-29 Fir de Conversatie Bram Moolenaar


Patch 8.2.2068
Problem:Transparent syntax item uses start/end of containing region.
Solution:   Do not change the startpos and endpos of a transparent region to
that of its containing region. (Adrian Ghizaru, closes #7349,
closes #7391)
Files:  src/syntax.c, src/testdir/test_syntax.vim


*** ../vim-8.2.2067/src/syntax.c2020-11-25 11:47:32.76080 +0100
--- src/syntax.c2020-11-29 14:06:10.935734932 +0100
***
*** 2606,2613 
{
sip->si_attr = CUR_STATE(idx - 1).si_attr;
sip->si_trans_id = CUR_STATE(idx - 1).si_trans_id;
-   sip->si_h_startpos = CUR_STATE(idx - 1).si_h_startpos;
-   sip->si_h_endpos = CUR_STATE(idx - 1).si_h_endpos;
if (sip->si_cont_list == NULL)
{
sip->si_flags |= HL_TRANS_CONT;
--- 2606,2611 
*** ../vim-8.2.2067/src/testdir/test_syntax.vim 2020-11-18 16:53:19.982914841 
+0100
--- src/testdir/test_syntax.vim 2020-11-29 14:10:22.143200503 +0100
***
*** 27,32 
--- 27,52 
return c
  endfunc
  
+ func AssertHighlightGroups(lnum, startcol, expected, trans = 1, msg = "")
+   " Assert that the characters starting at a given (line, col)
+   " sequentially match the expected highlight groups.
+   " If groups are provided as a string, each character is assumed to be a
+   " group and spaces represent no group, useful for visually describing tests.
+   let l:expectedGroups = type(a:expected) == v:t_string
+ \ ? a:expected->split('\zs')->map({_, v -> trim(v)})
+ \ : a:expected
+   let l:errors = 0
+   let l:msg = (a:msg->empty() ? "" : a:msg .. ": ")
+ \ .. "Wrong highlight group at " .. a:lnum .. ","
+ 
+   for l:i in range(a:startcol, a:startcol + l:expectedGroups->len() - 1)
+ let l:errors += synID(a:lnum, l:i, a:trans)
+   \ ->synIDattr("name")
+   \ ->assert_equal(l:expectedGroups[l:i - 1],
+   \l:msg .. l:i)
+   endfor
+ endfunc
+ 
  func Test_syn_iskeyword()
new
call setline(1, [
***
*** 824,827 
--- 844,923 
bwipe!
  endfunc
  
+ func Test_syn_contained_transparent()
+   " Comments starting with "Regression:" show the result when the highlighting
+   " span of the containing item is assigned to the contained region.
+   syntax on
+ 
+   let l:case = "Transparent region contained in region"
+   new
+   syntax region X start=/\[/ end=/\]/ contained transparent
+   syntax region Y start=/(/ end=/)/ contains=X
+ 
+   call setline(1,  "==(--[~~]--)==")
+   let l:expected = "  YY  "
+   eval AssertHighlightGroups(1, 1, l:expected, 1, l:case)
+   syntax clear Y X
+   bw!
+ 
+   let l:case = "Transparent region extends region"
+   new
+   syntax region X start=/\[/ end=/\]/ contained transparent
+   syntax region Y start=/(/ end=/)/ end=/e/ contains=X
+ 
+   call setline(1,  "==(--[~~e~~]--)==")
+   let l:expected = "  Y  "
+   " Regression:"  YYY   YYY  "
+   eval AssertHighlightGroups(1, 1, l:expected, 1, l:case)
+   syntax clear Y X
+   bw!
+ 
+   let l:case = "Nested transparent regions extend region"
+   new
+   syntax region X start=/\[/ end=/\]/ contained transparent
+   syntax region Y start=/(/ end=/)/ end=/e/ contains=X
+ 
+   call setline(1,  "==(--[~~e~~[~~e~~]~~e~~]--)==")
+   let l:expected = "  Y  "
+   " Regression:"  YYY Y  "
+   eval AssertHighlightGroups(1, 1, l:expected, 1, l:case)
+   syntax clear Y X
+   bw!
+ 
+   let l:case = "Transparent region contained in match"
+   new
+   syntax region X start=/\[/ end=/\]/ contained transparent
+   syntax match Y /(.\{-})/ contains=X
+ 
+   call setline(1,  "==(--[~~]--)==")
+   let l:expected = "  YY  "
+   eval AssertHighlightGroups(1, 1, l:expected, 1, l:case)
+   syntax clear Y X
+   bw!
+ 
+   let l:case = "Transparent region extends match"
+   new
+   syntax region X start=/\[/ end=/\]/ contained transparent
+   syntax match Y /(.\{-}[e)]/ contains=X
+ 
+   call setline(1,  "==(--[~~e~~]--)==")
+   let l:expected = "  YY "
+   " Regression:"  YYY"
+   eval AssertHighlightGroups(1, 1, l:expected, 1, l:case)
+   syntax clear Y X
+   bw!
+ 
+   let l:case = "Nested transparent regions extend match"
+   new
+   syntax region X start=/\[/ end=/\]/ contained transparent
+   syntax match Y /(.\{-}[e)]/ contains=X
+ 
+   call setline(1,  "==(--[~~e~~[~~e~~]~~e~~]--)==")
+   let l:expected = "  YY "
+   " Regression:"  YYY YY "
+   eval Asse