This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 67745 - awkward left brace after left paren
Summary: awkward left brace after left paren
Status: RESOLVED WONTFIX
Alias: None
Product: editor
Classification: Unclassified
Component: Key bindings (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-28 22:28 UTC by jrose
Modified: 2016-07-07 07:30 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jrose 2005-10-28 22:28:49 UTC
If I type a left paren, the editor puts in a right paren for me.
This is good.  If I finish typing the stuff in parens, and type a semicolon to finish the line,
then the caret moves outside the right paren.  That's good too.
What's bad is the behavior with left brace.  It should work like a semicolon, but doesn't.
If I type a method header or while header, the left brace gets caught inside the parens:
        for (;;{)

I keep tripping over this, and find it very awkward.
A left brace should be treated like a semi, and skip past the closing right paren.

Counting this as a defect because it is manifestly inconsistent with semicolon behavior.
Comment 1 Miloslav Metelka 2005-10-31 16:55:28 UTC
I mostly agree with you but please note that the {} can be used for array
contents initialization as well i.e. the following is also valid (though I agree
that seldom used) pattern:

        Object o[] = { "a", "b" };
        for (...; ...; o = new Object[] { "c", "d" }) {
            ...
        }

I would still prefer to treat this as enhancement. In the future once we will
have a local parsing available we should be able to treat the situation in the
context-sensitive way which would IMHO be an optimal solution here.
Comment 2 jrose 2005-10-31 19:01:30 UTC
Actually, I invented the anonymous array syntax, as well as the anonymous inner class syntax, in JDK 
1.1.  I'll extend the language lesson by pointing out that semicolons can occur inside expressions also, 
because of anonymous inner classes.  In such cases the NB editor pops the semicolon into the wrong 
place.

In the following example, the semicolon was typed after 'x' but moved to the end of the line:
   while (new Foo() { int x);

As you say, these are rare cases.  Even the case of iterating over an anonymous array is probably better 
stated using varargs, with no array initializers:
  for (String s : Arrays.asList("foo", "bar", "baz"))

We agree that semis and braces are rare inside parentheses.  In this bug I'm talking about the 99.999% 
case, where the semicolon or left brace goes to the end of the line.  What I'm asking for is parity of 
treatment between semicolon and left-brace.  My fingers are having a hard time learning the different 
typing rules.  Thanks for listening.
Comment 3 Martin Balin 2016-07-07 07:30:21 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss