diff --git a/crates/project/src/project_settings.rs b/crates/project/src/project_settings.rs index 10ffc986fa798011c28261d2ff899da66261669a..f3eda40406159e57bf798c1e0ac4ec07399a312a 100644 --- a/crates/project/src/project_settings.rs +++ b/crates/project/src/project_settings.rs @@ -697,6 +697,7 @@ impl SettingsObserver { None => proto::LocalSettingsKind::Settings, }; let path = RelPath::from_proto(&envelope.payload.path)?; + dbg!("got update worktree settings", &path); this.update(&mut cx, |this, cx| { let worktree_id = WorktreeId::from_proto(envelope.payload.worktree_id); let Some(worktree) = this diff --git a/crates/settings/src/settings_store.rs b/crates/settings/src/settings_store.rs index 5c4a97fa1373232972aac99a2f2abb1ae2810d97..9e74ba145e34282a8301145f02381dfc0acf7f61 100644 --- a/crates/settings/src/settings_store.rs +++ b/crates/settings/src/settings_store.rs @@ -844,6 +844,7 @@ impl SettingsStore { settings_content: Option<&str>, cx: &mut App, ) -> std::result::Result<(), InvalidSettingsError> { + dbg!(&kind, &directory_path); let mut zed_settings_changed = false; match ( kind, @@ -958,6 +959,7 @@ impl SettingsStore { } }; + dbg!(&self.local_settings); if zed_settings_changed { self.recompute_values(Some((root_id, &directory_path)), cx); } diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index 2a3f1865652b7c2b903ea0affbd81022e565cb3c..a880453df5c33ff549e56c80b2b8574ae9ba2c43 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -548,7 +548,6 @@ pub fn open_settings_editor( } // We have to defer this to get the workspace off the stack. - let path = path.map(ToOwned::to_owned); cx.defer(move |cx| { let current_rem_size: f32 = theme::ThemeSettings::get_global(cx).ui_font_size(cx).into(); @@ -1159,7 +1158,7 @@ fn all_language_names(cx: &App) -> Vec { } #[allow(unused)] -#[derive(Clone, PartialEq)] +#[derive(Clone, PartialEq, Debug)] enum SettingsUiFile { User, // Uses all settings. Project((WorktreeId, Arc)), // Has a special name, and special set of settings @@ -1823,7 +1822,7 @@ impl SettingsWindow { let prev_files = self.files.clone(); let settings_store = cx.global::(); let mut ui_files = vec![]; - let mut all_files = settings_store.get_all_files(); + let mut all_files = dbg!(settings_store.get_all_files()); if !all_files.contains(&settings::SettingsFile::User) { all_files.push(settings::SettingsFile::User); } @@ -1836,14 +1835,12 @@ impl SettingsWindow { } if let Some(worktree_id) = settings_ui_file.worktree_id() { - let directory_name = all_projects(cx) - .find_map(|project| project.read(cx).worktree_for_id(worktree_id, cx)) - .and_then(|worktree| worktree.read(cx).root_dir()) - .and_then(|root_dir| { - root_dir - .file_name() - .map(|os_string| os_string.to_string_lossy().to_string()) - }); + let directory_name = dbg!( + all_projects(Some(window), cx) + .find_map(|project| dbg!(project.read(cx).worktree_for_id(worktree_id, cx))) + .map(|worktree| dbg!(worktree.read(cx).root_name())) + ); + // .and_then(|root_dir| dbg!(dbg!(root_dir).file_name())); let Some(directory_name) = directory_name else { log::error!( @@ -1853,7 +1850,8 @@ impl SettingsWindow { continue; }; - self.worktree_root_dirs.insert(worktree_id, directory_name); + self.worktree_root_dirs + .insert(worktree_id, directory_name.as_unix_str().to_string()); } let focus_handle = prev_files @@ -1869,7 +1867,7 @@ impl SettingsWindow { let mut missing_worktrees = Vec::new(); - for worktree in all_projects(cx) + for worktree in all_projects(Some(window), cx) .flat_map(|project| project.read(cx).worktrees(cx)) .filter(|tree| !self.worktree_root_dirs.contains_key(&tree.read(cx).id())) { @@ -1899,6 +1897,7 @@ impl SettingsWindow { self.worktree_root_dirs.extend(missing_worktrees); + dbg!(&ui_files); self.files = ui_files; let current_file_still_exists = self .files @@ -3246,7 +3245,10 @@ impl Render for SettingsWindow { } } -fn all_projects(cx: &App) -> impl Iterator> { +fn all_projects( + window: Option<&Window>, + cx: &App, +) -> impl Iterator> { workspace::AppState::global(cx) .upgrade() .map(|app_state| { @@ -3255,7 +3257,15 @@ fn all_projects(cx: &App) -> impl Iterator> { .read(cx) .workspaces() .iter() + .inspect(|_| { + dbg!("workspace"); + }) .filter_map(|workspace| Some(workspace.read(cx).ok()?.project().clone())) + .chain( + dbg!(window.and_then(|window| dbg!(window.root::()))) + .flatten() + .map(|workspace| workspace.read(cx).project().clone()), + ) }) .into_iter() .flatten() @@ -3272,7 +3282,7 @@ fn update_settings_file( match file { SettingsUiFile::Project((worktree_id, rel_path)) => { let rel_path = rel_path.join(paths::local_settings_file_relative_path()); - let Some((worktree, project)) = all_projects(cx).find_map(|project| { + let Some((worktree, project)) = all_projects(None, cx).find_map(|project| { project .read(cx) .worktree_for_id(worktree_id, cx)