Buf Latest Version
GitHub repository with your minimal reproducible example (do not leave this field blank or fill out this field with "github.com/bufbuild/vscode-buf" or we will automatically close your issue, see the instructions above!)
https://github.com/happyhun/buf-lsp-empty-file-repro
steps
1. Clone the repository.
2. Open the repository root in VS Code.
3. Open `proto/hello.proto` before the Buf Language Server has successfully started.
4. Leave `proto/hello.proto` empty.
5. Wait for the Buf Language Server to start.
On the initial startup, the language server repeatedly crashes and VS Code eventually reports:
The Buf Language Server server crashed 5 times in the last 3 minutes.
If the Buf Language Server has already started successfully, opening or creating an empty `.proto` file does not appear to reproduce the issue.
Output
The Buf Language Server crashes repeatedly with a panic and VS Code eventually stops restarting it.
The relevant error is:
panic: runtime error: index out of range [1] with length 1
The stack trace includes:
github.com/bufbuild/protocompile/experimental/source.(*File).LineOffsets
github.com/bufbuild/protocompile/experimental/source.inverseLocation
github.com/bufbuild/protocompile/experimental/source.(*File).InverseLocation
github.com/bufbuild/buf/private/buf/buflsp.(*server).getOrganizeImportsCodeAction
github.com/bufbuild/buf/private/buf/buflsp.(*server).CodeAction
VS Code eventually reports:
The Buf Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted.
Expected Output
The Buf Language Server should start successfully and remain running when an empty .proto file is opened during initial startup.
Opening an empty .proto file should not cause the language server to panic or restart repeatedly.
Anything else?
One additional observation: I may have triggered the crash after creating an empty .proto file and typing only:
syntax = "proto3";
I’m not completely certain whether the crash happened while the file was still fully empty or immediately after typing that line, so it may be worth testing both cases.
Also, once the Buf Language Server has successfully started, I have not been able to reproduce the crash by opening or creating an empty .proto file. The issue appears to be specific to the initial LSP startup.
Buf Latest Version
buf.GitHub repository with your minimal reproducible example (do not leave this field blank or fill out this field with "github.com/bufbuild/vscode-buf" or we will automatically close your issue, see the instructions above!)
https://github.com/happyhun/buf-lsp-empty-file-repro
steps
Output
The Buf Language Server crashes repeatedly with a panic and VS Code eventually stops restarting it.
The relevant error is:
panic: runtime error: index out of range [1] with length 1
The stack trace includes:
github.com/bufbuild/protocompile/experimental/source.(*File).LineOffsets
github.com/bufbuild/protocompile/experimental/source.inverseLocation
github.com/bufbuild/protocompile/experimental/source.(*File).InverseLocation
github.com/bufbuild/buf/private/buf/buflsp.(*server).getOrganizeImportsCodeAction
github.com/bufbuild/buf/private/buf/buflsp.(*server).CodeAction
VS Code eventually reports:
The Buf Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted.
Expected Output
The Buf Language Server should start successfully and remain running when an empty
.protofile is opened during initial startup.Opening an empty
.protofile should not cause the language server to panic or restart repeatedly.Anything else?
One additional observation: I may have triggered the crash after creating an empty
.protofile and typing only:syntax = "proto3";
I’m not completely certain whether the crash happened while the file was still fully empty or immediately after typing that line, so it may be worth testing both cases.
Also, once the Buf Language Server has successfully started, I have not been able to reproduce the crash by opening or creating an empty
.protofile. The issue appears to be specific to the initial LSP startup.