mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:43 +00:00
[ty] Avoid panicking when there are multiple workspaces (#18151)
## Summary This PR updates the language server to avoid panicking when there are multiple workspace folders passed during initialization. The server currently picks up the first workspace folder and provides a warning and a log message. ## Test Plan <img width="1724" alt="Screenshot 2025-05-17 at 11 43 09" src="https://github.com/user-attachments/assets/1a7ddbc3-198d-4191-a28f-9b69321e8f99" />
This commit is contained in:
parent
76ab3425d3
commit
32403dfb28
2 changed files with 22 additions and 4 deletions
|
@ -96,10 +96,20 @@ impl Server {
|
|||
anyhow::anyhow!("Failed to get the current working directory while creating a default workspace.")
|
||||
})?;
|
||||
|
||||
if workspaces.len() > 1 {
|
||||
// TODO(dhruvmanila): Support multi-root workspaces
|
||||
anyhow::bail!("Multi-root workspaces are not supported yet");
|
||||
}
|
||||
let workspaces = if workspaces.len() > 1 {
|
||||
let first_workspace = workspaces.into_iter().next().unwrap();
|
||||
tracing::warn!(
|
||||
"Multiple workspaces are not yet supported, using the first workspace: {}",
|
||||
&first_workspace.0
|
||||
);
|
||||
show_warn_msg!(
|
||||
"Multiple workspaces are not yet supported, using the first workspace: {}",
|
||||
&first_workspace.0
|
||||
);
|
||||
vec![first_workspace]
|
||||
} else {
|
||||
workspaces
|
||||
};
|
||||
|
||||
Ok(Self {
|
||||
connection,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue