dominikh / go-mode.el

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

Incorrect filling of first line #373

Closed phst closed 3 years ago

phst commented 3 years ago

M-q doesn't fill the very first line of a buffer. To reproduce, create a Go mode buffer with contents such as

// a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
// a a a a a

Even though the first line is longer than 70 columns, M-q doesn't refill the comment. Adding a line break before the first comment line will make this work as expected.

The underlying problem is that (go--fill-forward-paragraph -1) after or in the comment moves to the beginning of the second line instead of the first. I think the problem is that the (forward-line single) form can't move beyond the beginning of the buffer, and the loops in go--fill-forward-paragraph need to be adapted for this edge case.