Skip to content

Commit 8e07908

Browse files
committed
runtime(sh): Update indent script
closes: #19110 Signed-off-by: Christian Brabandt <[email protected]>
1 parent 4936e76 commit 8e07908

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

runtime/indent/sh.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
" License: Vim (see :h license)
88
" Repository: https://github.com/chrisbra/vim-sh-indent
99
" Changelog:
10+
" 20250906 - indent function closing properly on multiline commands
1011
" 20250318 - Detect local arrays in functions
1112
" 20241411 - Detect dash character in function keyword for
1213
" bash mode (issue #16049)
@@ -186,6 +187,15 @@ function! GetShIndent()
186187
endif
187188
endif
188189

190+
" Special case: if the current line is a closing '}', align with matching '{'
191+
if curline =~ '^\s*}\s*$'
192+
let match_lnum = searchpair('{', '', '}', 'bnW',
193+
\ 'synIDattr(synID(line("."),col("."), 1),"name") =~? "comment\\|quote"')
194+
if match_lnum > 0
195+
return indent(match_lnum)
196+
endif
197+
endif
198+
189199
return ind > 0 ? ind : 0
190200
endfunction
191201

0 commit comments

Comments
 (0)