]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.1.1187: matchparen plugin wrong highlights shell case statement v9.1.1187
authorChristian Brabandt <cb@256bit.org>
Sun, 9 Mar 2025 07:40:33 +0000 (08:40 +0100)
committerChristian Brabandt <cb@256bit.org>
Sun, 9 Mar 2025 07:40:33 +0000 (08:40 +0100)
commit9102ac11ab3938ec8c15bfebd00d2f91d3f1cd6c
tree6ceb8ad030012c476d0bd2cc570d74f4ba60484a
parentd89770eb987768aca78fef74d8d8601ce53fc435
patch 9.1.1187: matchparen plugin wrong highlights shell case statement

Problem:  matchparen plugin wrong highlights shell case statement
          (Swudu Susuwu)
Solution: return early, if we are in a shSnglCase syntax element

The shell syntax element "case $var in foobar)" uses closing parenthesis
but there is no corresponding opening parenthesis for that syntax
element. However matchparen is not aware of such things and will happily
try to match just the next opening parenthesis.

So let's just add a way to opt out for such cases. In this case, use the
syntax state to check if the closing parenthesis belongs to the syntax
item "shSnglCase" and if it is, do not try to find a corresponding
opening parenthesis.

Since inspecting the syntax state might be expensive, put the whole
check behind a filetype test, so that matchparen will only perform this
particular check, when it knows the current buffer is a "sh" filetype.

fixes: #16801
closes: #16831

Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/plugin/matchparen.vim
src/testdir/dumps/Test_matchparen_sh_case_1.dump [new file with mode: 0644]
src/testdir/test_plugin_matchparen.vim
src/version.c