On Thursday, August 14th, 2014 at 11:31AM, Daniel Hahler wrote:
> 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

I can reproduce this. The patch Daniel sent fixes it, but I believe it has
a small typo. Daniel, can you compare the patch I'm sending and tell me if
it fixes the problem. (In the version you sent, there seems to be
a misplaced closing parenthesis, unless I'm confused.)


> 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.

I took over maintaining this indentation file, and I'd hoped to write
a set of tests, but haven't gotten around to it. Any suggestions or help
are always welcome.

Thanks, Peter
-- 
We have not been faced with the need to satisfy someone else's
requirements, and for this freedom we are grateful.
    Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System

-- 
-- 
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 -r 18fd959b07ef runtime/indent/sh.vim
--- a/runtime/indent/sh.vim     Wed Aug 13 22:05:54 2014 +0200
+++ b/runtime/indent/sh.vim     Thu Aug 14 11:59:26 2014 -0400
@@ -91,7 +91,9 @@
     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')

Raspunde prin e-mail lui