Loading ...
Sorry, an error occurred while loading the content.

[patch] improper indentation with shell case statements (ft=sh)

Expand Messages
  • Daniel Hahler
    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
    Message 1 of 5 , Aug 14, 2014
    • 0 Attachment
      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 vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/d/optout.
    • Peter Aronoff
      ... 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
      Message 2 of 5 , Aug 14, 2014
      • 0 Attachment
        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 vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/d/optout.
      • Peter Aronoff
        ... Looking at it again, I did misread. Daniel s original version is correct, though now I m thinking I want to reread order of operations to decide why both
        Message 3 of 5 , Aug 14, 2014
        • 0 Attachment
          On Thursday, August 14th, 2014 at 9:17PM, Peter Aronoff wrote:
          > 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.)

          Looking at it again, I did misread. Daniel's original version is correct,
          though now I'm thinking I want to reread order of operations to decide why
          both versions work and under what conditions one would fail.

          Bram: In any case, I believe you should pull in Daniel's fix. (If you would
          rather me send the full file with the change already present, I can do
          that, but not until early next week. I'll be away the next few days.)

          Sorry for the initial confusion.

          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 vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/d/optout.
        • Bram Moolenaar
          ... I do prefer you send me the whole updated file. That avoids mistakes. -- The History of every major Galactic Civilization tends to pass through three
          Message 4 of 5 , Aug 15, 2014
          • 0 Attachment
            Peter Aronoff wrote:

            > On Thursday, August 14th, 2014 at 9:17PM, Peter Aronoff wrote:
            > > 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.)
            >
            > Looking at it again, I did misread. Daniel's original version is correct,
            > though now I'm thinking I want to reread order of operations to decide why
            > both versions work and under what conditions one would fail.
            >
            > Bram: In any case, I believe you should pull in Daniel's fix. (If you would
            > rather me send the full file with the change already present, I can do
            > that, but not until early next week. I'll be away the next few days.)
            >
            > Sorry for the initial confusion.

            I do prefer you send me the whole updated file. That avoids mistakes.

            --
            The History of every major Galactic Civilization tends to pass through
            three distinct and recognizable phases, those of Survival, Inquiry and
            Sophistication, otherwise known as the How, Why and Where phases.
            For instance, the first phase is characterized by the question 'How can
            we eat?' the second by the question 'Why do we eat?' and the third by
            the question 'Where shall we have lunch?'
            -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"

            /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
            /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
            \\\ an exciting new programming language -- http://www.Zimbu.org ///
            \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

            --
            --
            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 vim_dev+unsubscribe@....
            For more options, visit https://groups.google.com/d/optout.
          • Gary Johnson
            As long as you re working on indent/sh.vim, would you please look at fixing this, too? { echo this } ( echo that ) The problem is that statements within
            Message 5 of 5 , Aug 20, 2014
            • 0 Attachment
              As long as you're working on indent/sh.vim, would you please look at
              fixing this, too?

              {
              echo this
              }
              (
              echo that
              )

              The problem is that statements within parentheses are not indented.
              They should be indented the same as statements within braces.

              Regards,
              Gary

              --
              --
              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 vim_dev+unsubscribe@....
              For more options, visit https://groups.google.com/d/optout.
            Your message has been successfully submitted and would be delivered to recipients shortly.