Skip to content

Commit 2fcf6fd

Browse files
authored
fix(lsp): avoid panic when current_dir is unavailable
1 parent 29bc001 commit 2fcf6fd

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

crates/lsp/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ impl LanguageServer {
128128
let config = load_config(workspace_root.as_deref());
129129

130130
#[cfg(not(target_arch = "wasm32"))]
131-
let workspace_root = workspace_root.unwrap_or_else(|| std::env::current_dir().unwrap());
131+
let workspace_root = workspace_root.unwrap_or_else(|| {
132+
std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."))
133+
});
132134

133135
#[cfg(target_arch = "wasm32")]
134136
let _ = workspace_root;

0 commit comments

Comments
 (0)