[vim/vim] indent/sh.vim treats ${#array[@]} as an opening block (Issue #21440)

4 views
Skip to first unread message

Marcel Hüttenberger

unread,
Oct 3, 2026, 4:56:22 PM (3 days ago) Oct 3
to vim/vim, Subscribed
papachaotica created an issue (vim/vim#21440)

Version

Vim 9.1, Debian package (runtime/indent/sh.vim is in use).

Steps to reproduce

Create a Bash file containing:

#!/bin/bash

scans=(a.png b.png)

printf '%d\n' "${#scans[@]}"
    for scan in "${scans[@]}"; do
        :
    done

or

if (( SPLIT == 0 )); then
    split=${#output[@]}
    else
        split="$SPLIT"
fi 


${#scans[@]} is a Bash parameter expansion that returns the array length. It is not an opening { block.

# possible fix - line 320-322
function! s:start_block(line)
-   return a:line =~ '^[^#]*[{(]\s*\(#.*\)\?$'
+  return a:line =~ '^[^#]*\$\@<![{(]\s*\(#.*\)\?$'
endfunction

—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/21440@github.com>

Reply all
Reply to author
Forward
0 new messages