Repository: astral-sh/ruff
File: crates/ty_server/src/session.rs (Rust)

Code before:
        self.projects.values_mut().chain(default_project)
    }

    pub(crate) fn initialize_workspaces(
        &mut self,
        workspace_settings: Vec<(Url, ClientOptions)>,
        client: &Client,
    ) {
        assert!(!self.workspaces.all_initialized());

        // These are the options combined from all the global options received by the server for
        // each workspace via the workspace configuration request.
        let mut combined_global_options: Option<GlobalOptions> = None;

        for (url, options) in workspace_settings {
            // Combine the global options specified during initialization with the
            // workspace-specific options to create the final workspace options.
            let ClientOptions {
                global, workspace, ..
            } = self
                .initialization_options
                .options
                .clone()
                .combine(options.clone());

            tracing::debug!("Initializing workspace `{url}: {global:#?}`");

            let unknown_options = &options.unknown;
            if !unknown_options.is_empty() {
                warn_about_unknown_options(client, Some(&url), unknown_options);
            }

            combined_global_options.combine_with(Some(global));

            let workspace_settings = workspace.into_settings();
            let Some((root, workspace)) = self.workspaces.initialize(&url, workspace_settings)
            else {
                continue;
            };

            // For now, create one project database per workspace.
            // In the future, index the workspace directories to find all projects
            // and create a project database for each.
            let system = LSPSystem::new(
                self.index.as_ref().unwrap().clone(),
                self.native_system.clone(),
            );

            let project = ProjectMetadata::discover(&root, &system)
                .context("Failed to discover project configuration")
                .and_then(|mut metadata| {

Review comment (bug):
```suggestion
            tracing::debug!("Initializing workspace `{url}`: {global:#?}");
```

Code after:
        self.projects.values_mut().chain(default_project)
    }

    pub(crate) fn initialize_workspaces(
        &mut self,
        workspace_settings: Vec<(Url, ClientOptions)>,
        client: &Client,
    ) {
        assert!(!self.workspaces.all_initialized());

        // These are the options combined from all the global options received by the server for
        // each workspace via the workspace configuration request.
        let mut combined_global_options: Option<GlobalOptions> = None;

        for (url, options) in workspace_settings {
            // Combine the global options specified during initialization with the
            // workspace-specific options to create the final workspace options.
            let ClientOptions {
                global, workspace, ..
            } = self
                .initialization_options
                .options
                .clone()
                .combine(options.clone());

            tracing::debug!("Initializing workspace `{url}`: {workspace:#?}");

            let unknown_options = &options.unknown;
            if !unknown_options.is_empty() {
                warn_about_unknown_options(client, Some(&url), unknown_options);
            }

            combined_global_options.combine_with(Some(global));

            let Ok(root) = url.to_file_path() else {
                tracing::debug!("Ignoring workspace with non-path root: {url}");
                continue;
            };

            // Realistically I don't think this can fail because we got the path from a Url
            let root = match SystemPathBuf::from_path_buf(root) {
                Ok(root) => root,
                Err(root) => {
                    tracing::debug!(
                        "Ignoring workspace with non-UTF8 root: {root}",
                        root = root.display()
                    );
                    continue;
                }
            };