Bug 153923 - [typing][validateEdit][content assist] Can not insert newline when filling in arguments
Summary: [typing][validateEdit][content assist] Can not insert newline when filling in...
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 419898 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-08-15 11:19 EDT by Randy Hudson CLA
Modified: 2014-12-01 11:01 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Randy Hudson CLA 2006-08-15 11:19:28 EDT
I type in:

new SomeClassName(<<CARET>>);

and invoke content assist and choose the constructor I want. Now I'm filling in parameters using the "tooltip" prompt. The constructor takes many parameters and I'd like to insert a newline while filling in parameters. When I press ENTER, instead of a newline, the caret is placed at the end of the constructor call:

new SomeClassName(constantpool.contantx, )<<CARET>>;

Note that this only occurs when auto-close parenthesis is enabled, and the starting case involved typing the parens, followed by invoking content assist.

Suggested fix, ENTER to close auto-parens should not occur while the method/constructor argument hint window is visible. Only ")" should be active.
Comment 1 Dani Megert CLA 2013-10-21 08:11:19 EDT
*** Bug 419898 has been marked as a duplicate of this bug. ***
Comment 2 Dani Megert CLA 2013-10-21 08:14:11 EDT
A possible (more generic) solution would be to add the new line when some modifier is pressed while pressing 'Enter'. Like e.g. Shift+Enter currently ends the statement and adds a new line.
Comment 3 Sergey Prigogin CLA 2014-11-26 22:02:21 EST
(In reply to Dani Megert from comment #2)
> A possible (more generic) solution would be to add the new line when some
> modifier is pressed while pressing 'Enter'. Like e.g. Shift+Enter currently
> ends the statement and adds a new line.

I don't quite understand why insertion of the newline should be conditioned on a modifier. Why not insert the newline whenever Enter is pressed? If the user wants the cursor to move outside of the closing parenthesis she can always press End.
Comment 4 Missing name CLA 2014-11-26 23:02:04 EST
(In reply to Sergey Prigogin from comment #3)
> I don't quite understand why insertion of the newline should be conditioned
> on a modifier. Why not insert the newline whenever Enter is pressed? If the
> user wants the cursor to move outside of the closing parenthesis she can
> always press End.

This makes more sense to me. I want to insert a newline when I press Enter.
Comment 5 Dani Megert CLA 2014-11-27 04:41:30 EST
(In reply to Sergey Prigogin from comment #3)
> (In reply to Dani Megert from comment #2)
> > A possible (more generic) solution would be to add the new line when some
> > modifier is pressed while pressing 'Enter'. Like e.g. Shift+Enter currently
> > ends the statement and adds a new line.
> 
> I don't quite understand why insertion of the newline should be conditioned
> on a modifier. Why not insert the newline whenever Enter is pressed? If the
> user wants the cursor to move outside of the closing parenthesis she can
> always press End.

Because 'Enter' first/mainly means: "choose the selected argument. As a bonus, we then move to the next one, or after the bracket if it was the last one:

1. new HashMap<code assist> and choose the int,float constructor
   ==> new HashMap<>([initialCapacity], loadFactor)
2. you can now choose between initialCapacity and 0, hit 'Enter'
   ==> new HashMap<>(0, [loadFactor])

For most people it would be a pain if 'Enter' adds a newline or doesn't move to the next argument in this scenario.


Maybe a better approach would be to apply the formatter preference and already insert the newlines accordingly when the constructor is inserted:

new HashMap<code assist> and choose the int,float constructor
==> new HashMap<>([initialCapacity],
           loadFactor)
in that case, 'Enter' would then result in this:
    new HashMap<>(initialCapacity,
           [loadFactor])
Comment 6 Randy Hudson CLA 2014-12-01 11:01:57 EST
(In reply to Dani Megert from comment #5)
> Because 'Enter' first/mainly means: "choose the selected argument. As a
> bonus, we then move to the next one, or after the bracket if it was the last
> one:
> 
> 1. new HashMap<code assist> and choose the int,float constructor
>    ==> new HashMap<>([initialCapacity], loadFactor)
> 2. you can now choose between initialCapacity and 0, hit 'Enter'
>    ==> new HashMap<>(0, [loadFactor])

I always thought TAB was used to do this.  i.e., similar to navigating across "focusable" controls in a dialog.  And I never really need to use the TAB key unless I'm at the beginning of a line.