diff options
author | Roland Kovacs | 2022-04-13 01:02:14 +0000 |
---|---|---|
committer | GitHub | 2022-04-13 01:02:14 +0000 |
commit | a0c6c45c1b5dc36f3c5151363d3f360bea388a99 (patch) | |
tree | f4cc9ecce5fcaa8f2dcfd059d5e228c706109f3e /helix-view | |
parent | 3deb1c92306877e4d99c45f20f61c17c5e980492 (diff) |
Fix panic when using set-language on a scratch (#1996)
Skip launching a language server if a document doesn't have a valid URL.
Diffstat (limited to 'helix-view')
-rw-r--r-- | helix-view/src/editor.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index c4e9ec28..76fc6713 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -453,6 +453,9 @@ impl Editor { /// Launch a language server for a given document fn launch_language_server(ls: &mut helix_lsp::Registry, doc: &mut Document) -> Option<()> { + // if doc doesn't have a URL it's a scratch buffer, ignore it + let doc_url = doc.url()?; + // try to find a language server based on the language name let language_server = doc.language.as_ref().and_then(|language| { ls.get(language) @@ -476,7 +479,7 @@ impl Editor { // TODO: this now races with on_init code if the init happens too quickly tokio::spawn(language_server.text_document_did_open( - doc.url().unwrap(), + doc_url, doc.version(), doc.text(), language_id, |