From 9a6819b89912b3367f2c1ffe82f481f5e6616c36 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 10 Mar 2022 16:06:12 -0800 Subject: [PATCH] For single-file worktrees start LSP with parent dir as CWD --- crates/lsp/src/lsp.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rs index d9024975e4..a8b715f020 100644 --- a/crates/lsp/src/lsp.rs +++ b/crates/lsp/src/lsp.rs @@ -109,8 +109,13 @@ impl LanguageServer { options: Option, background: Arc, ) -> Result { + let working_dir = if root_path.is_dir() { + root_path + } else { + root_path.parent().unwrap_or(Path::new("/")) + }; let mut server = Command::new(binary_path) - .current_dir(root_path) + .current_dir(working_dir) .args(args) .stdin(Stdio::piped()) .stdout(Stdio::piped())