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 148755 - NetBeans code completion inserts parenthesis automatically
Summary: NetBeans code completion inserts parenthesis automatically
Status: RESOLVED WONTFIX
Alias: None
Product: editor
Classification: Unclassified
Component: Completion & Templates (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-30 15:29 UTC by vieiro
Modified: 2010-11-25 09:50 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vieiro 2008-09-30 15:29:14 UTC
While typing NetBeans inserts closing parenthesis automatically.

This is very annoying, because I type them too, without noticing. 

So I end up with two parenthesis, and I have to go to the end of the line and delete the NetBeans' extra parenthesis
(but not mine) and I waste a lot of time.

I think there should be an option to disable that annoying behaviour.
Comment 1 Petr Dvorak 2008-09-30 15:46:48 UTC
You can disable this in Tools>Options>Editor>General - just uncheck "Insert Closing Bracket Automatically" checkbox. If
this does not help, please reopen this issue.
Comment 2 vieiro 2008-10-01 08:44:57 UTC
To reproduce do the following:

1.- Make sure that Tools>Options>Editor>General is unchecked
2.- Start writing a method that takes at least one argument, ask for code completion for the method.
3.- When the code completion window appears then just press enter to accept the given method.
4.- NetBeans selects the argument, but adds an extra ")" after it
5.- Modify the name of the argument (selected by NetBeans), there's an extra ")" there.
6.- You are obligated to press "supr" to remove that extra ")" or "end" or "->" to go after the parenthesis.

Step "6" is annoying becasue it breaks your normal way of writing, and makes you fight NetBeans editor (that gets in the
way). If you're typing fast (as I do) this is very annoying.

I'd suggest that code completion fills in the name of the argument(s), but does not add any extra ")" afterwards.

Comment 3 Miloslav Metelka 2008-10-01 11:17:04 UTC
Well if you would just press Enter then the argument would be completed and caret would be beyond ')'. But I agree that
this may change your typing habits.

So technically we will have to
1) allow code-template-processor to end editing upon insertion of certain characters e.g. ')' (the processor must
control position of the char (e.g. ')' in a string literal is harmless).
2) make sure that even with "Insert Closing Bracket Automatically" (and no CC opened) the typed ')' must skip the ending
bracket pasted as a custom code-template by CC (note that in a regular typing the ')' would not be skipped).
Comment 4 Max Sauer 2008-10-01 13:00:42 UTC
It would be nice if we could insert closing parenthesis when pressing ';' (semicolon) in order to select an completion item, which is a method invocation 
without parameters -- regardless of  "Insert Closing Bracket Automatically". ie:

- have "Insert Closing Bracket Automatically" unchecked
- type System.out.printl
- invoke CC, press ';'
=> System.out.println(;

parenthesis is missing.
Comment 5 vieiro 2008-10-02 07:59:57 UTC
> Well if you would just press Enter then the argument would be completed and caret would be beyond ')

Not really. If the method has no arguments then the caret is after the ')'. But if the method has at least one argument
then the first argument remains selected, a little "red" square surrounds it, and the caret is immediately *before* the ')'.

This behaviour (having the caret either after or before the ')' depending on the number of arguments) makes it complex
to type fast in the editor: the editor gets in your way, and you have to type extra keys to get over it.

I wonder if I could disable any module to have this solved?

Thanks,
Antonio
Comment 6 Vitezslav Stejskal 2008-10-02 12:05:42 UTC
> I wonder if I could disable any module to have this solved?

No, you can't. This is done in the CC infrastructure, which can't be removed unless you want to strip down the IDE to
almost the bare platform.
Comment 7 Max Sauer 2008-11-27 14:16:58 UTC
It would be nice to have this in 7.0.
Comment 8 Sergey Petrov 2009-05-15 10:51:35 UTC
in my opinion it's not an issue, code completion create complete method with some default variables if possible,
sometimes it's not necessary to do anything after code completion, sometimes need to replace some parts.
Comment 9 binarydigit09 2009-10-27 17:29:46 UTC
I feel the same way as joshis.  I like to manage my own closing parenthesis and would be very grateful if I could tell
NetBeans to let me handle them myself.
Comment 10 Dusan Balek 2010-11-25 09:50:56 UTC
Current code completion behavior is as designed. You have intentionally asked for code completion in step 2 and used it by pressing 'Enter' in step 3. So the whole method gets code completed, including initial argument values and both parens. That's how the feature that you have used works. (Comparing this behavior with automatic bracket completion, closing bracket/brace/parenthesis is completed automatically - without any intentional user input - just after typing matching opening bracket/brace/parenthesis. So in this case, it is reasonable to have the option switching this behavior off).
As for modifying method arguments (surrounded by a little red square), 'Enter' can be used to iterate through them (each time pressing 'Enter', the next argument is selected, pressing 'Enter' with the last argument selected, selection disappears and cursor is moved after the closing parenthesis).

Closing as WONTFIX.