Do not remove worktrees after the headless server removal (#19556)

Release Notes:

- N/A

Co-authored-by: Conrad Irwin <conrad@zed.dev>
This commit is contained in:
Kirill Bulatov 2024-10-22 19:27:50 +03:00 committed by GitHub
parent 291ca2c32c
commit edda149d75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 12 additions and 4 deletions

View file

@ -831,7 +831,7 @@ impl AllLanguageSettings {
let editorconfig_properties = location.and_then(|location| {
cx.global::<SettingsStore>()
.editorconfg_properties(location.worktree_id, location.path)
.editorconfig_properties(location.worktree_id, location.path)
});
if let Some(editorconfig_properties) = editorconfig_properties {
let mut settings = settings.clone();

View file

@ -1029,6 +1029,7 @@ impl LspStore {
})
.detach()
}
WorktreeStoreEvent::WorktreeReleased(..) => {}
WorktreeStoreEvent::WorktreeRemoved(_, id) => self.remove_worktree(*id, cx),
WorktreeStoreEvent::WorktreeOrderChanged => {}
WorktreeStoreEvent::WorktreeUpdateSent(worktree) => {

View file

@ -2223,9 +2223,11 @@ impl Project {
cx.emit(Event::WorktreeAdded);
}
WorktreeStoreEvent::WorktreeRemoved(_, id) => {
self.on_worktree_removed(*id, cx);
cx.emit(Event::WorktreeRemoved(*id));
}
WorktreeStoreEvent::WorktreeReleased(_, id) => {
self.on_worktree_released(*id, cx);
}
WorktreeStoreEvent::WorktreeOrderChanged => cx.emit(Event::WorktreeOrderChanged),
WorktreeStoreEvent::WorktreeUpdateSent(_) => {}
}
@ -2261,7 +2263,7 @@ impl Project {
cx.notify();
}
fn on_worktree_removed(&mut self, id_to_remove: WorktreeId, cx: &mut ModelContext<Self>) {
fn on_worktree_released(&mut self, id_to_remove: WorktreeId, cx: &mut ModelContext<Self>) {
if let Some(dev_server_project_id) = self.dev_server_project_id {
let paths: Vec<String> = self
.visible_worktrees(cx)

View file

@ -62,6 +62,7 @@ pub struct WorktreeStore {
pub enum WorktreeStoreEvent {
WorktreeAdded(Model<Worktree>),
WorktreeRemoved(EntityId, WorktreeId),
WorktreeReleased(EntityId, WorktreeId),
WorktreeOrderChanged,
WorktreeUpdateSent(Model<Worktree>),
}
@ -394,6 +395,10 @@ impl WorktreeStore {
let handle_id = worktree.entity_id();
cx.observe_release(worktree, move |this, worktree, cx| {
cx.emit(WorktreeStoreEvent::WorktreeReleased(
handle_id,
worktree.id(),
));
cx.emit(WorktreeStoreEvent::WorktreeRemoved(
handle_id,
worktree.id(),

View file

@ -968,7 +968,7 @@ impl SettingsStore {
Ok(())
}
pub fn editorconfg_properties(
pub fn editorconfig_properties(
&self,
for_worktree: WorktreeId,
for_path: &Path,