-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix panic when using set-language on a scratch buffer #1996
Fix panic when using set-language on a scratch buffer #1996
Conversation
Would this cause any problems with the LSP? |
Yeah, you are right. It seems to require that the URI is a valid file path, which is a bit.. not good... Also the scatch buffer URIs have to be unique otherwise it seems to complain as well and get super confused about edits. I've tried what happens if I generate a file URI as Edit: |
762fc50
to
b615c88
Compare
Alright, I think this covers everything. I found no protocol errors and the scratch connection is cleaned up. 2022-04-07T22:13:43.321 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"rust","text":"\n","uri":"file:///usr/home/zen3ger/project/helix/scratch1","version":0}}}
.
.
.
2022-04-07T22:14:06.535 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":12,"line":1},"start":{"character":12,"line":1}},"text":";"}],"textDocument":{"uri":"file:///usr/home/zen3ger/project/helix/scratch1","version":25}}}
2022-04-07T22:14:20.113 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didClose","params":{"textDocument":{"uri":"file:///usr/home/zen3ger/project/helix/scratch1"}}}
2022-04-07T22:14:20.168 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"c","text":"int main(void) {\n return 0;\n}\n","uri":"file:///usr/home/zen3ger/project/helix/nothing.c","version":25}}} |
Should we set language servers for scratch buffers or just ignore them instead until they get saved with a path? How does vscode or neovim handle such cases? I don't think we should use fake filenames. |
ignoring until they get saved sounds better to me; the reason I tried this was to get syntax highlighting/tree-sitter and these would presumably still function without a language server further, the scratch buffer might end up somewhere arbitrary, or only loosely related to the current session |
Why didn't I think about the obvious solution...
If I'm not mistaken in neovim LSP is not started when you do |
Let's ignore scratch buffers then. |
Skip launching a language server if a document doesn't have a valid URL.
b615c88
to
888ebeb
Compare
Skip launching a language server if a document doesn't have a valid URL.
Closes #1994