]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(sh): Update indent script
authorChristian Brabandt <cb@256bit.org>
Thu, 8 Jan 2026 20:52:01 +0000 (20:52 +0000)
committerChristian Brabandt <cb@256bit.org>
Thu, 8 Jan 2026 20:52:01 +0000 (20:52 +0000)
closes: #19110

Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/indent/sh.vim

index a1abd1d0afa85238a518d1d292ec704b41087f40..daf9170bf3d8dca5cc1a2d5b4817cb41350c8a9e 100644 (file)
@@ -7,6 +7,7 @@
 " License:             Vim (see :h license)
 " Repository:          https://github.com/chrisbra/vim-sh-indent
 " Changelog:
+"          20250906  - indent function closing properly on multiline commands
 "          20250318  - Detect local arrays in functions
 "          20241411  - Detect dash character in function keyword for
 "                      bash mode (issue #16049)
@@ -186,6 +187,15 @@ function! GetShIndent()
     endif
   endif
 
+  " Special case: if the current line is a closing '}', align with matching '{'
+  if curline =~ '^\s*}\s*$'
+    let match_lnum = searchpair('{', '', '}', 'bnW',
+      \ 'synIDattr(synID(line("."),col("."), 1),"name") =~? "comment\\|quote"')
+    if match_lnum > 0
+      return indent(match_lnum)
+    endif
+  endif
+
   return ind > 0 ? ind : 0
 endfunction