diff --git a/runtime/ftplugin/shaderslang.vim b/runtime/ftplugin/shaderslang.vim index f3d1ab8c1c..900bc6dd9b 100644 --- a/runtime/ftplugin/shaderslang.vim +++ b/runtime/ftplugin/shaderslang.vim @@ -1,7 +1,7 @@ " Vim filetype plugin file " Language: Slang " Maintainer: Austin Shijo -" Last Change: 2025 Jan 05 +" Last Change: 2026 Aug 16 " Only do this when not done yet for this buffer if exists("b:did_ftplugin") @@ -28,12 +28,9 @@ setlocal commentstring=//\ %s setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,:// " When the matchit plugin is loaded, this makes the % command skip parens and -" braces in comments properly, and adds support for shader-specific keywords +" braces in comments properly if exists("loaded_matchit") - " Add common shader control structures - let b:match_words = '{\|^\s*\<\(if\|for\|while\|switch\|struct\|class\)\>:}\|^\s*\,' .. - \ '^\s*#\s*if\(\|def\|ndef\)\>:^\s*#\s*elif\>:^\s*#\s*else\>:^\s*#\s*endif\>,' .. - \ '\[:\]' + let b:match_words = '^\s*#\s*if\(\|def\|ndef\)\>:^\s*#\s*elif\>:^\s*#\s*else\>:^\s*#\s*endif\>' let b:match_skip = 's:comment\|string\|character\|special' let b:match_ignorecase = 0 let b:undo_ftplugin ..= " | unlet! b:match_skip b:match_words b:match_ignorecase" diff --git a/test/old/testdir/test_plugin_matchit.vim b/test/old/testdir/test_plugin_matchit.vim index 1c8144278d..cbff2a6da0 100644 --- a/test/old/testdir/test_plugin_matchit.vim +++ b/test/old/testdir/test_plugin_matchit.vim @@ -55,4 +55,22 @@ func Test_html_matchit_tag_multiline_attributes() bwipe! endfunc +func Test_shaderslang_matchit_switch_break() + call s:Setup(['void main() {', ' switch (x) {', ' case 1:', + \ ' break;', ' }', '}'], 'shaderslang') + call assert_equal(5, s:PercentTo([2, 14])) + call assert_equal(2, s:PercentTo([5, 3])) + bwipe! +endfunc + +func Test_shaderslang_matchit_loop_break() + call s:Setup(['void f() {', ' for (int i = 0; i < 4; ++i) {', + \ ' if (i == 2)', ' break;', ' total += i;', ' }', + \ ' int after = 1;', '}'], 'shaderslang') + call assert_equal(8, s:PercentTo([1, 10])) + call assert_equal(6, s:PercentTo([2, 31])) + call assert_equal(2, s:PercentTo([6, 3])) + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab