GRECLIPSE
  1. GRECLIPSE
  2. GRECLIPSE-1172

Unwanted automatic closing of braces in a GString

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5.1Release
    • Fix Version/s: 2.5.2.Release
    • Component/s: Editor, Project Settings
    • Labels:
      None
    • Environment:
      STS 2.7.1, Grails 1.3.7
    • Number of attachments :
      0

      Description

      On typing "${" in a GString, the editor will immediately add a closing brace "}" character after the cursor, even if the Java Editor preferences specify not to automatically close braces. I expect these editor preferences to be inherited by the Groovy Editor. These unwanted closing braces interfere with my ability to type fluidly, are a constant source of annoyance, and cause a lot of accidental errors while coding.

      This issue might relate to behaviour introduced by the patch for issue GRECLIPSE-795. A comment there states:

      This patch adds auto insertion of "}" braces after "${" while editing Strings.

      A little of extra logic was also added to not insert the extra closing brace if it seems there's one already there.

      Please fix this issue and respect the Java Editor preference not to automatically close braces.

        Activity

        Hide
        Andrew Eisenberg added a comment -

        Assigning this one to Kris since he was the one who originally created the patch.

        Show
        Andrew Eisenberg added a comment - Assigning this one to Kris since he was the one who originally created the patch.
        Hide
        D Gardner added a comment -

        If the worst comes to the worst and, for whatever reason, it is necessary to insert a "}" into my code against my wishes, it would be less terrible if I could move the cursor after the "}" using the Tab key. This kind of Tab key cursor positioning is a common feature in Eclipse editors when code templates or other kinds of auto-completion are used.

        Show
        D Gardner added a comment - If the worst comes to the worst and, for whatever reason, it is necessary to insert a "}" into my code against my wishes, it would be less terrible if I could move the cursor after the "}" using the Tab key. This kind of Tab key cursor positioning is a common feature in Eclipse editors when code templates or other kinds of auto-completion are used.
        Hide
        Andrew Eisenberg added a comment -

        You're lucky. 3 of your bugs to be fixed in one day.

        I took a look at this one as well and I have a fix for it locally. It seems like the autoclose for refs in GStrings was implemented differently from other autoclosers. I folded this implementation into the existing infrastructure that handles autoclosing of (, <, ", ', """, and '''.

        I also linked the preference to the Preferences -> Java -> Editor -> Typing -> Automatically Close -> Braces. Uncheck that option and the braces will not auto-close for you.

        Show
        Andrew Eisenberg added a comment - You're lucky. 3 of your bugs to be fixed in one day. I took a look at this one as well and I have a fix for it locally. It seems like the autoclose for refs in GStrings was implemented differently from other autoclosers. I folded this implementation into the existing infrastructure that handles autoclosing of (, <, ", ', """, and '''. I also linked the preference to the Preferences -> Java -> Editor -> Typing -> Automatically Close -> Braces. Uncheck that option and the braces will not auto-close for you.
        Hide
        Andrew Eisenberg added a comment -

        Fixed with regression tests, but will wait to commit this until svn repo is open for commits again.

        Show
        Andrew Eisenberg added a comment - Fixed with regression tests, but will wait to commit this until svn repo is open for commits again.
        Hide
        D Gardner added a comment -

        Thank you very much, Andrew. I really appreciate the attention that you've been giving to the issues that I have reported over the past few weeks.

        Does auto-complete still work as expected with the changes you have made? I notice that auto-complete usually breaks if the closing brace is not present in the GString. I suspect that is the reason why GRECLIPSE-795 added the brace if it was missing. It wasn't the right fix (to my mind), but I wonder if removing it the automatic closing will regress that earlier issue.

        Show
        D Gardner added a comment - Thank you very much, Andrew. I really appreciate the attention that you've been giving to the issues that I have reported over the past few weeks. Does auto-complete still work as expected with the changes you have made? I notice that auto-complete usually breaks if the closing brace is not present in the GString. I suspect that is the reason why GRECLIPSE-795 added the brace if it was missing. It wasn't the right fix (to my mind), but I wonder if removing it the automatic closing will regress that earlier issue.
        Hide
        Andrew Eisenberg added a comment -

        Having an unclosed curly in a gstring will cause the groovy parser to fail and none of the file will be able to be parsed.

        The fix that I made for this bug was to use a different and more precise mechanism to autoclose. Now, they are autoclosed only if the preference is set. Also, pressing tab or an extra '}' will navigate you to outside of the closing curly. So. there should not be any regression.

        Show
        Andrew Eisenberg added a comment - Having an unclosed curly in a gstring will cause the groovy parser to fail and none of the file will be able to be parsed. The fix that I made for this bug was to use a different and more precise mechanism to autoclose. Now, they are autoclosed only if the preference is set. Also, pressing tab or an extra '}' will navigate you to outside of the closing curly. So. there should not be any regression.

          People

          • Assignee:
            Andrew Eisenberg
            Reporter:
            D Gardner
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: