saibing / bingo

Bingo is a Go language server that speaks Language Server Protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

panic: illegal Pos value

jackielii opened this issue · comments

panic serving textDocument/formatting: illegal Pos value
goroutine 5438 [running]:
github.com/saibing/bingo/langserver/internal/util.Panicf(0x8ec580, 0xa5b410, 0x9ac64c, 0x2, 0xc0156fd830, 0x1, 0x1, 0xc0156fd840, 0x45b086)
	/home/jackieli/gomod/bingo/langserver/internal/util/util.go:116 +0x93
github.com/saibing/bingo/langserver.(*LangHandler).Handle.func1(0xc00b282000, 0xc0156fde60)
	/home/jackieli/gomod/bingo/langserver/handler.go:114 +0xc4
panic(0x8ec580, 0xa5b410)
	/usr/local/go/src/runtime/panic.go:513 +0x1b9
go/token.(*File).Offset(...)
	/usr/local/go/src/go/token/position.go:263
github.com/saibing/bingo/langserver.toProtocolEdits(0xa65c20, 0xc019f1e780, 0xc014e3a200, 0x7, 0x8, 0xc35aa7, 0xc014e3a200, 0x7)
	/home/jackieli/gomod/bingo/langserver/format.go:81 +0x345
github.com/saibing/bingo/langserver.formatRange(0xa653a0, 0xc010bec580, 0xa65620, 0xc0091368c0, 0xc011abc000, 0x47, 0x0, 0x8d2201, 0xc0160fe000, 0x0, ...)
	/home/jackieli/gomod/bingo/langserver/format.go:62 +0x1d4
github.com/saibing/bingo/langserver.(*LangHandler).handleTextDocumentFormatting(0xc0001e6000, 0xa653a0, 0xc010bec580, 0xa637e0, 0xc0001d6180, 0xc00b282000, 0xc011abc000, 0x47, 0x4, 0x0, ...)
	/home/jackieli/gomod/bingo/langserver/format.go:24 +0xba
github.com/saibing/bingo/langserver.(*LangHandler).Handle(0xc0001e6000, 0xa653a0, 0xc010bec580, 0xa637e0, 0xc0001d6180, 0xc00b282000, 0x0, 0x0, 0x0, 0x0)
	/home/jackieli/gomod/bingo/langserver/handler.go:323 +0x2185
github.com/saibing/bingo/langserver.(*LangHandler).handle(0xc0001e6000, 0xa653e0, 0xc0000aa010, 0xc0001d6180, 0xc00b282000, 0x95af80, 0x1, 0xc01950d2b0, 0xc000413728)
	/home/jackieli/gomod/bingo/langserver/handler.go:104 +0x66
github.com/saibing/bingo/langserver.(*LangHandler).handle-fm(0xa653e0, 0xc0000aa010, 0xc0001d6180, 0xc00b282000, 0xc000413728, 0x9a7b8566adabbacd, 0x20, 0x94efc0)
	/home/jackieli/gomod/bingo/langserver/handler.go:26 +0x52
github.com/sourcegraph/jsonrpc2.(*HandlerWithErrorConfigurer).Handle(0xc000152230, 0xa653e0, 0xc0000aa010, 0xc0001d6180, 0xc00b282000)
	/home/jackieli/go/pkg/mod/github.com/sourcegraph/jsonrpc2@v0.0.0-20180831160525-549eb959f029/handler_with_error.go:21 +0x73
created by github.com/saibing/bingo/langserver.lspHandler.Handle
	/home/jackieli/gomod/bingo/langserver/handler.go:50 +0xfb
<-- error #266: textDocument/formatting: {"code":0,"message":"unexpected panic: illegal Pos value","data":null}
[Error - 17:40:39] Request textDocument/formatting failed.
  Message: unexpected panic: illegal Pos value
  Code: 0 ```

A repository containing full reproduction example will help. Also are you running with these flags:

...
    "go.languageServerFlags": [
        "-trace",
        "-enhance-signature-help",
        "-format-style=goimports",
        "-diagnostics-style=onsave",
        "-maxparallelism=8",
    ],
...

I.e., -format-style=goimports.

somehow if I manually add the import and restart the editor, it all start working again.

If it happens again I'll come back and re-open with more details report