You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you invoke code assist at "|" and you choose bar:, the result is: def b = new MyBean(foo: 'hello', bar: __, )
The trailing comma automatically inserted by code assist is more annoying than useful to me. It is meant to save the user to type it in case there are more parameters to add, but in fact it ends up to allow the user to type just as many characters as he/she has to type if he/she manually inserts ", " after each parameter, which is way more natural for me.
Suppose you want to call: def b = new MyBean(foo: 'foo', bar: 'bar')
and you start from: def b = new MyBean(
currently, you have to type (let's assume string constants are just one key):
(1) Ctrl+Space, (2) down arrow (to choose foo:), (3) Enter (to accept foo:), (4) 'foo', (5) TAB, (6) Ctrl+Space, (7) Enter (to accept bar:), (8) 'bar', (9) TAB, (10) backspace (to remove trailing space), (11) backspace (to remove trailing comma), (12) closed parenthesis
You can save 2 keys if at point (9) you remember to hit DEL (instead of TAB) and then you close parenthesis.
So, currently you have to type 12 or 10 keys.
If there were no trailing comma and space, you will have to type:
(1) Ctrl+Space, (2) down arrow (to choose foo:), (3) Enter (to accept foo:), (4) 'foo', (5) comma, (6) space, (7) Ctrl+Space, (8) Enter (to accept bar:), (9) 'bar', (10) closed parenthesis.
If you don't want the space between fields, you'll have one less key to type.
So, in the worst case, you have to type the same amount of characters.
Fact is that it's unnatural to me to remember to press TAB and DEL to properly complete this kind of statement. I would very much prefer to have full control over commas and spaces between fields.
The only case in which I find the insertion of the trailing ", " useful is when you're accepting a suggestion for a parameter which is not the last one, i.e. suppose you have MyBean.setBaz(String) as well and you are at: def b = new MyBean(foo: 'foo', | bar: 'bar')
when you invoke code assist at "|" and accept baz: the result is: def b = new MyBean(foo: 'foo', baz: __, bar: 'bar')
(although please note how the trailing space is still redundant, because it adds an extra space before the next field).
So, maybe an option to disable the automatic ", " insertion, at least for the last field in a map-style constructor invocation (or to disable it completely) would be very appreciated.
The text was updated successfully, but these errors were encountered:
Insertion of named parameter proposals without trailing comma-space is ready to test. If you trigger the proposal with , it should be inserted at the end of the completion. The comma was part of the completions for the longest time because the JDT components that have been leveraged for named parameter proposals did not insert the comma when typed and this made it difficult to complete multiple named parameters.
eric-milles
changed the title
Allow to disable the annoying trailing ", " inserted in map-style constructor call code assist
Remove trailing ", " from map-style constructor call named argument proposals
Feb 21, 2018
Hi Eric,
I've tested with 3.0.0.xx-201802211752-e47 and the trailing ", " is not inserted any more, thanks a lot!!
However, triggering the proposal with , does not work for me (it seems like comma is not recognized as trigger character at all). Not that important for me...
Consider the following:
and the following Groovy class:
When you invoke code assist at "|" and you choose
bar:
, the result is:def b = new MyBean(foo: 'hello', bar: __, )
The trailing comma automatically inserted by code assist is more annoying than useful to me. It is meant to save the user to type it in case there are more parameters to add, but in fact it ends up to allow the user to type just as many characters as he/she has to type if he/she manually inserts ", " after each parameter, which is way more natural for me.
Suppose you want to call:
def b = new MyBean(foo: 'foo', bar: 'bar')
and you start from:
def b = new MyBean(
currently, you have to type (let's assume string constants are just one key):
(1) Ctrl+Space, (2) down arrow (to choose
foo:
), (3) Enter (to acceptfoo:
), (4)'foo'
, (5) TAB, (6) Ctrl+Space, (7) Enter (to acceptbar:
), (8)'bar'
, (9) TAB, (10) backspace (to remove trailing space), (11) backspace (to remove trailing comma), (12) closed parenthesisYou can save 2 keys if at point (9) you remember to hit DEL (instead of TAB) and then you close parenthesis.
So, currently you have to type 12 or 10 keys.
If there were no trailing comma and space, you will have to type:
(1) Ctrl+Space, (2) down arrow (to choose
foo:
), (3) Enter (to acceptfoo:
), (4) 'foo', (5) comma, (6) space, (7) Ctrl+Space, (8) Enter (to acceptbar:
), (9) 'bar', (10) closed parenthesis.If you don't want the space between fields, you'll have one less key to type.
So, in the worst case, you have to type the same amount of characters.
Fact is that it's unnatural to me to remember to press TAB and DEL to properly complete this kind of statement. I would very much prefer to have full control over commas and spaces between fields.
The only case in which I find the insertion of the trailing ", " useful is when you're accepting a suggestion for a parameter which is not the last one, i.e. suppose you have
MyBean.setBaz(String)
as well and you are at:def b = new MyBean(foo: 'foo', | bar: 'bar')
when you invoke code assist at "|" and accept
baz:
the result is:def b = new MyBean(foo: 'foo', baz: __, bar: 'bar')
(although please note how the trailing space is still redundant, because it adds an extra space before the next field).
So, maybe an option to disable the automatic ", " insertion, at least for the last field in a map-style constructor invocation (or to disable it completely) would be very appreciated.
The text was updated successfully, but these errors were encountered: