2022.3: Trailing comma is not working anymore
Answered
Hello,
I am using 2022.3.1 (Ultimate Edition). When I am defining a map like this, I expected to see editor insert comma after I type in "b": 2 and press enter. It does not do that.
func foo() {
m := map[string]int {
"a": 1,
// Expected IntelliJ to put in trailing comma, once I press enter after typing 2.
// It does not do that in 2022.3.1. It used to do that in 2022.1
"b": 2
}
fmt.Printf("m %v", m)
}
I used to use 2022.1. Trailing commas were automatic in that version. Can you suggest if this a bug or there is smoother knob to turn this feature on?
Best
-Vasu
Please sign in to leave a comment.
Hi,
Could you please elaborate a bit? After what action are you expecting Go plugin to add a comma? Will it work if you invoke Code | Reformat Code?
I took a screen recording, to show this issue.
Code/Reformat Code fixes the trailing comma. But, 2022.1 used to do this automatically.
https://youtu.be/GKpQ3P-JPN8
In the original post, I tried to share a snippet with a comment saying what is expected from Editor. I am trying to create a map. And when I add key-value pairs manually, I expected editor to add trailing comma after every line. That is not happening.
Code/Reformat Code fixes the trailing comma. But, 2022.1 I used to do this automatically.
I took a screen recording, to show this issue. I shared it via YouTube, looks like that post is under review. So posting it here.
I'm not sure that the feature worked in this way. GoLand or IntelliJ IDEA with Go plugin inserts a comma if you select some items in the completion pop-up.
I also downloaded the 2022.1.4 version to see if it works differently, but it doesn't insert commas for hand-typed values.
Thank you for checking. After seeing you response I downloaded 2022.1 to verify my claims. It did not support it. So, I might have been mistaken.
On the other hand, it would be a good feature to have.
Indeed, feel free to follow GO-14273.