dominikh / go-mode.el

Emacs mode for the Go programming language
BSD 3-Clause "New" or "Revised" License
1.37k stars 209 forks source link

Indenting problem for map or slice variable define: var foo = map[int] int { #344

Closed netjune closed 4 years ago

netjune commented 4 years ago

For example:

var foo = map[int]int {
    1:1,
        2:2,
        3:3,
}

And if I delete a whitespace in the first line (the whitespce before '{'), then it is indented like this:

var foo = map[int]int{
    1:1,
    2:2,
    3:3,
}
muirdm commented 4 years ago

Why is there a space there?

We use the lack of whitespace to tell the difference between a composite literal curly and a function curly. I don't think there is much value in trying to fix this because gofmt removes the space and normally one doesn't put a space there.

netjune commented 4 years ago

Then no problem since it is expected. Thanks.