[vim/vim] Regression from patch 8.2.2761: groups names after `contains=TOP,` are ignored in included syntax file (Issue #11277)

18 views
Skip to first unread message

zeertzjq

unread,
Oct 4, 2022, 9:19:40 AM10/4/22
to vim/vim, Subscribed

Steps to reproduce

  1. Run vim --clean
  2. Source the following file (this example is based on test from patch 8.2.2761):
syntax include @INCLUDED syntax/c.vim
syntax region FencedCodeBlockC start=/```c/ end=/```/ contains=@INCLUDED

call setline(1,  ['```c', '#if 0', 'int', '#else', 'int', '#if', '#endif', '```' ])
  1. The #if on line 6 is highlighted as cPreCondit:
    Screenshot_20221004_211303

Expected behaviour

The #if on line 6 should not be highlighted as cPreCondit, because of this line in syntax file c.vim:

  syn region	cCppOutElse	contained matchgroup=cCppOutWrapper start="^\s*\%(%:\|#\)\s*\%(else\|elif\)" end="^\s*\%(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit

It behaves correctly with a C file alone:
Screenshot_20221004_211315

Version of Vim

9.0.354

Environment

Operating system: Arch Linux
Terminal: kitty
Value of $TERM: xterm-kitty
Shell: fish

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11277@github.com>

zeertzjq

unread,
Oct 4, 2022, 9:22:00 AM10/4/22
to vim/vim, Subscribed

If patch 8.2.2761 is reverted, the #if is highlighted correctly, but the int is not:
Screenshot_20221004_212043


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11277/1266989183@github.com>

Bram Moolenaar

unread,
Oct 4, 2022, 4:44:46 PM10/4/22
to vim/vim, Subscribed

Do you know how to fix it? What if you revert (part of) patch 8.2.2761 ?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11277/1267555769@github.com>

zeertzjq

unread,
Oct 4, 2022, 9:12:17 PM10/4/22
to vim/vim, Subscribed

I guess this is actually always broken. Looking at the code, it seems that both CONTAINED and TOP behave differently in an included syntax file from a top-level syntax file.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11277/1267789774@github.com>

Bram Moolenaar

unread,
Oct 5, 2022, 7:52:36 AM10/5/22
to vim/vim, Subscribed

Yes, it appears unrelated to "syntax include".

If I change "contains=TOP,cPreCondit" from the cCppOutElse rule it seems to work better.
But then adding "#if/#endif" above the "#else" breaks the "out" highlight.
This may require another "contained" rule to match the nested #if/#endif


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11277/1268333952@github.com>

zeertzjq

unread,
Oct 5, 2022, 11:25:42 AM10/5/22
to vim/vim, Subscribed

BTW, there is a more practical example using syntax/lua.vim:

syntax include @INCLUDED syntax/lua.vim
syntax region FencedCodeBlockLua start=/```lua/ end=/```/ contains=@INCLUDED

call setline(1,  ['```lua', 'print(1)', '```' ])

The last parenthesis is highlighted as luaParenError:
Screenshot_20221005_232047

It shouldn't be highlighted luaParenError as it is specified after contains=TOP, in syntax/lua.vim:

syn region luaParen transparent start='(' end=')' contains=TOP,luaParenError


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11277/1268592093@github.com>

Virginia Senioria

unread,
Sep 15, 2023, 12:54:27 PM9/15/23
to vim/vim, Subscribed

It seems this is because syn include would simply replace all TOP to the cluster name, thus contains=TOP,luaParenError becomes contains=@INCLUDED,luaParenError. And unfortunately, the two similar syntaxes have contradictory semantics: while the former prevents luaParenError from being contained in region luaParen, the latter allows luaParenError to be contained. According to the document, both syn include and contains` seems to work as intended.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11277/1721578370@github.com>

Furkan Alp Tokaç

unread,
Nov 16, 2023, 5:20:55 PM11/16/23
to vim/vim, Subscribed

It's unbelievable that this issue has been open for more than a year.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11277/1815406668@github.com>

Christian Brabandt

unread,
Nov 16, 2023, 5:34:21 PM11/16/23
to vim/vim, Subscribed

It's unbelievable that this issue has been open for more than a year.

We are only a limited number of people and can only do so much. However we are not obliged to provide you with fixes or even features. It may look strange, but we are doing this in our (limited) spare time for free for our users.

If you want to have this fixed, I invite you to help the community, analyze the issue, find the part in the code, fix it, create a test so that it doesn't regress and send a patch instead of complaining loudly and showing no respect to the work we are doing here.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11277/1815420444@github.com>

Reply all
Reply to author
Forward
0 new messages