The following code gets indented wrong (with filetype=sh):
case "$1" in
foo) echo "foo";;
bar) echo "bar";;
esac
I would expect it to look like this:
case "$1" in
foo) echo "foo";;
bar) echo "bar";;
esac
The attached patch fixes this:
diff --git i/runtime/indent/sh.vim w/runtime/indent/sh.vim
index 68f764e..d98f415 100644
--- i/runtime/indent/sh.vim
+++ w/runtime/indent/sh.vim
@@ -91,7 +91,9 @@ function! GetShIndent()
if s:is_case(pine)
let ind = indent(lnum) + s:indent_value('case-labels')
else
- let ind -= s:indent_value('case-statements') -
s:indent_value('case-breaks')
+ let ind -= (s:is_case_label(pine, lnum) && s:is_case_ended(pine) ?
+ \ 0 : s:indent_value('case-statements')) -
+ \ s:indent_value('case-breaks')
endif
elseif s:is_case_break(line)
let ind -= s:indent_value('case-breaks')
It would be nice to also have a test for this, but I was not sure where to put
it and how to approach it.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git i/runtime/indent/sh.vim w/runtime/indent/sh.vim
index 68f764e..d98f415 100644
--- i/runtime/indent/sh.vim
+++ w/runtime/indent/sh.vim
@@ -91,7 +91,9 @@ function! GetShIndent()
if s:is_case(pine)
let ind = indent(lnum) + s:indent_value('case-labels')
else
- let ind -= s:indent_value('case-statements') - s:indent_value('case-breaks')
+ let ind -= (s:is_case_label(pine, lnum) && s:is_case_ended(pine) ?
+ \ 0 : s:indent_value('case-statements')) -
+ \ s:indent_value('case-breaks')
endif
elseif s:is_case_break(line)
let ind -= s:indent_value('case-breaks')