According to currently gopls's internal implementation, end point's offset is always -1, which makes the Offset() panic. Actually, as I tested in my neovim environment, checking file's ending is unnecessary now, so I removed these logic, and it works fine for me.
internal/source's line and column number always starts from 1, so we should correct it first. Otherwise code formatting cannot work properly.
There are two problems in code formatting:
According to currently
gopls
's internal implementation, end point's offset is always-1
, which makes theOffset()
panic. Actually, as I tested in my neovim environment, checking file's ending is unnecessary now, so I removed these logic, and it works fine for me.internal/source
's line and column number always starts from1
, so we should correct it first. Otherwise code formatting cannot work properly.@saibing PTAL