Merge branch 'main' into ui-scrollbar-teardown

This commit is contained in:
MrSubidubi 2025-08-20 10:48:16 +02:00
commit 76842eed31
598 changed files with 18423 additions and 13109 deletions

View file

@ -498,7 +498,7 @@ impl ProjectPanel {
if let Some((worktree, expanded_dir_ids)) = project
.read(cx)
.worktree_for_id(*worktree_id, cx)
.zip(this.expanded_dir_ids.get_mut(&worktree_id))
.zip(this.expanded_dir_ids.get_mut(worktree_id))
{
let worktree = worktree.read(cx);
@ -558,7 +558,7 @@ impl ProjectPanel {
if project_panel
.edit_state
.as_ref()
.map_or(false, |state| state.processing_filename.is_none())
.is_some_and(|state| state.processing_filename.is_none())
{
project_panel.edit_state = None;
project_panel.update_visible_entries(None, cx);
@ -641,8 +641,8 @@ impl ProjectPanel {
focus_opened_item,
allow_preview,
} => {
if let Some(worktree) = project.read(cx).worktree_for_entry(entry_id, cx) {
if let Some(entry) = worktree.read(cx).entry_for_id(entry_id) {
if let Some(worktree) = project.read(cx).worktree_for_entry(entry_id, cx)
&& let Some(entry) = worktree.read(cx).entry_for_id(entry_id) {
let file_path = entry.path.clone();
let worktree_id = worktree.read(cx).id();
let entry_id = entry.id;
@ -692,11 +692,10 @@ impl ProjectPanel {
}
}
}
}
}
&Event::SplitEntry { entry_id } => {
if let Some(worktree) = project.read(cx).worktree_for_entry(entry_id, cx) {
if let Some(entry) = worktree.read(cx).entry_for_id(entry_id) {
if let Some(worktree) = project.read(cx).worktree_for_entry(entry_id, cx)
&& let Some(entry) = worktree.read(cx).entry_for_id(entry_id) {
workspace
.split_path(
ProjectPath {
@ -707,7 +706,6 @@ impl ProjectPanel {
)
.detach_and_log_err(cx);
}
}
}
_ => {}
@ -991,10 +989,10 @@ impl ProjectPanel {
if let Some(parent_path) = entry.path.parent() {
let snapshot = worktree.snapshot();
let mut child_entries = snapshot.child_entries(parent_path);
if let Some(child) = child_entries.next() {
if child_entries.next().is_none() {
return child.kind.is_dir();
}
if let Some(child) = child_entries.next()
&& child_entries.next().is_none()
{
return child.kind.is_dir();
}
};
false
@ -1005,10 +1003,10 @@ impl ProjectPanel {
let snapshot = worktree.snapshot();
let mut child_entries = snapshot.child_entries(&entry.path);
if let Some(child) = child_entries.next() {
if child_entries.next().is_none() {
return child.kind.is_dir();
}
if let Some(child) = child_entries.next()
&& child_entries.next().is_none()
{
return child.kind.is_dir();
}
}
false
@ -1021,12 +1019,12 @@ impl ProjectPanel {
cx: &mut Context<Self>,
) {
if let Some((worktree, entry)) = self.selected_entry(cx) {
if let Some(folded_ancestors) = self.ancestors.get_mut(&entry.id) {
if folded_ancestors.current_ancestor_depth > 0 {
folded_ancestors.current_ancestor_depth -= 1;
cx.notify();
return;
}
if let Some(folded_ancestors) = self.ancestors.get_mut(&entry.id)
&& folded_ancestors.current_ancestor_depth > 0
{
folded_ancestors.current_ancestor_depth -= 1;
cx.notify();
return;
}
if entry.is_dir() {
let worktree_id = worktree.id();
@ -1068,12 +1066,12 @@ impl ProjectPanel {
fn collapse_entry(&mut self, entry: Entry, worktree: Entity<Worktree>, cx: &mut Context<Self>) {
let worktree = worktree.read(cx);
if let Some(folded_ancestors) = self.ancestors.get_mut(&entry.id) {
if folded_ancestors.current_ancestor_depth + 1 < folded_ancestors.max_ancestor_depth() {
folded_ancestors.current_ancestor_depth += 1;
cx.notify();
return;
}
if let Some(folded_ancestors) = self.ancestors.get_mut(&entry.id)
&& folded_ancestors.current_ancestor_depth + 1 < folded_ancestors.max_ancestor_depth()
{
folded_ancestors.current_ancestor_depth += 1;
cx.notify();
return;
}
let worktree_id = worktree.id();
let expanded_dir_ids =
@ -1126,23 +1124,23 @@ impl ProjectPanel {
window: &mut Window,
cx: &mut Context<Self>,
) {
if let Some(worktree_id) = self.project.read(cx).worktree_id_for_entry(entry_id, cx) {
if let Some(expanded_dir_ids) = self.expanded_dir_ids.get_mut(&worktree_id) {
self.project.update(cx, |project, cx| {
match expanded_dir_ids.binary_search(&entry_id) {
Ok(ix) => {
expanded_dir_ids.remove(ix);
}
Err(ix) => {
project.expand_entry(worktree_id, entry_id, cx);
expanded_dir_ids.insert(ix, entry_id);
}
if let Some(worktree_id) = self.project.read(cx).worktree_id_for_entry(entry_id, cx)
&& let Some(expanded_dir_ids) = self.expanded_dir_ids.get_mut(&worktree_id)
{
self.project.update(cx, |project, cx| {
match expanded_dir_ids.binary_search(&entry_id) {
Ok(ix) => {
expanded_dir_ids.remove(ix);
}
});
self.update_visible_entries(Some((worktree_id, entry_id)), cx);
window.focus(&self.focus_handle);
cx.notify();
}
Err(ix) => {
project.expand_entry(worktree_id, entry_id, cx);
expanded_dir_ids.insert(ix, entry_id);
}
}
});
self.update_visible_entries(Some((worktree_id, entry_id)), cx);
window.focus(&self.focus_handle);
cx.notify();
}
}
@ -1152,20 +1150,20 @@ impl ProjectPanel {
window: &mut Window,
cx: &mut Context<Self>,
) {
if let Some(worktree_id) = self.project.read(cx).worktree_id_for_entry(entry_id, cx) {
if let Some(expanded_dir_ids) = self.expanded_dir_ids.get_mut(&worktree_id) {
match expanded_dir_ids.binary_search(&entry_id) {
Ok(_ix) => {
self.collapse_all_for_entry(worktree_id, entry_id, cx);
}
Err(_ix) => {
self.expand_all_for_entry(worktree_id, entry_id, cx);
}
if let Some(worktree_id) = self.project.read(cx).worktree_id_for_entry(entry_id, cx)
&& let Some(expanded_dir_ids) = self.expanded_dir_ids.get_mut(&worktree_id)
{
match expanded_dir_ids.binary_search(&entry_id) {
Ok(_ix) => {
self.collapse_all_for_entry(worktree_id, entry_id, cx);
}
Err(_ix) => {
self.expand_all_for_entry(worktree_id, entry_id, cx);
}
self.update_visible_entries(Some((worktree_id, entry_id)), cx);
window.focus(&self.focus_handle);
cx.notify();
}
self.update_visible_entries(Some((worktree_id, entry_id)), cx);
window.focus(&self.focus_handle);
cx.notify();
}
}
@ -1240,20 +1238,20 @@ impl ProjectPanel {
}
fn select_previous(&mut self, _: &SelectPrevious, window: &mut Window, cx: &mut Context<Self>) {
if let Some(edit_state) = &self.edit_state {
if edit_state.processing_filename.is_none() {
self.filename_editor.update(cx, |editor, cx| {
editor.move_to_beginning_of_line(
&editor::actions::MoveToBeginningOfLine {
stop_at_soft_wraps: false,
stop_at_indent: false,
},
window,
cx,
);
});
return;
}
if let Some(edit_state) = &self.edit_state
&& edit_state.processing_filename.is_none()
{
self.filename_editor.update(cx, |editor, cx| {
editor.move_to_beginning_of_line(
&editor::actions::MoveToBeginningOfLine {
stop_at_soft_wraps: false,
stop_at_indent: false,
},
window,
cx,
);
});
return;
}
if let Some(selection) = self.selection {
let (mut worktree_ix, mut entry_ix, _) =
@ -1330,39 +1328,37 @@ impl ProjectPanel {
.project
.read(cx)
.worktree_for_id(edit_state.worktree_id, cx)
&& let Some(entry) = worktree.read(cx).entry_for_id(edit_state.entry_id)
{
if let Some(entry) = worktree.read(cx).entry_for_id(edit_state.entry_id) {
let mut already_exists = false;
if edit_state.is_new_entry() {
let new_path = entry.path.join(filename.trim_start_matches('/'));
if worktree
.read(cx)
.entry_for_path(new_path.as_path())
.is_some()
{
already_exists = true;
}
} else {
let new_path = if let Some(parent) = entry.path.clone().parent() {
parent.join(&filename)
} else {
filename.clone().into()
};
if let Some(existing) = worktree.read(cx).entry_for_path(new_path.as_path())
{
if existing.id != entry.id {
already_exists = true;
}
}
};
if already_exists {
edit_state.validation_state = ValidationState::Error(format!(
"File or directory '{}' already exists at location. Please choose a different name.",
filename
));
cx.notify();
return;
let mut already_exists = false;
if edit_state.is_new_entry() {
let new_path = entry.path.join(filename.trim_start_matches('/'));
if worktree
.read(cx)
.entry_for_path(new_path.as_path())
.is_some()
{
already_exists = true;
}
} else {
let new_path = if let Some(parent) = entry.path.clone().parent() {
parent.join(&filename)
} else {
filename.clone().into()
};
if let Some(existing) = worktree.read(cx).entry_for_path(new_path.as_path())
&& existing.id != entry.id
{
already_exists = true;
}
};
if already_exists {
edit_state.validation_state = ValidationState::Error(format!(
"File or directory '{}' already exists at location. Please choose a different name.",
filename
));
cx.notify();
return;
}
}
let trimmed_filename = filename.trim();
@ -1466,14 +1462,13 @@ impl ProjectPanel {
}
Ok(CreatedEntry::Included(new_entry)) => {
project_panel.update( cx, |project_panel, cx| {
if let Some(selection) = &mut project_panel.selection {
if selection.entry_id == edited_entry_id {
if let Some(selection) = &mut project_panel.selection
&& selection.entry_id == edited_entry_id {
selection.worktree_id = worktree_id;
selection.entry_id = new_entry.id;
project_panel.marked_entries.clear();
project_panel.expand_to_selection(cx);
}
}
project_panel.update_visible_entries(None, cx);
if is_new_entry && !is_dir {
project_panel.open_entry(new_entry.id, true, false, cx);
@ -1606,11 +1601,11 @@ impl ProjectPanel {
directory_id = entry.id;
break;
} else {
if let Some(parent_path) = entry.path.parent() {
if let Some(parent_entry) = worktree.entry_for_path(parent_path) {
entry = parent_entry;
continue;
}
if let Some(parent_path) = entry.path.parent()
&& let Some(parent_entry) = worktree.entry_for_path(parent_path)
{
entry = parent_entry;
continue;
}
return;
}
@ -1664,57 +1659,56 @@ impl ProjectPanel {
worktree_id,
entry_id,
}) = self.selection
&& let Some(worktree) = self.project.read(cx).worktree_for_id(worktree_id, cx)
{
if let Some(worktree) = self.project.read(cx).worktree_for_id(worktree_id, cx) {
let sub_entry_id = self.unflatten_entry_id(entry_id);
if let Some(entry) = worktree.read(cx).entry_for_id(sub_entry_id) {
#[cfg(target_os = "windows")]
if Some(entry) == worktree.read(cx).root_entry() {
let sub_entry_id = self.unflatten_entry_id(entry_id);
if let Some(entry) = worktree.read(cx).entry_for_id(sub_entry_id) {
#[cfg(target_os = "windows")]
if Some(entry) == worktree.read(cx).root_entry() {
return;
}
if Some(entry) == worktree.read(cx).root_entry() {
let settings = ProjectPanelSettings::get_global(cx);
let visible_worktrees_count =
self.project.read(cx).visible_worktrees(cx).count();
if settings.hide_root && visible_worktrees_count == 1 {
return;
}
if Some(entry) == worktree.read(cx).root_entry() {
let settings = ProjectPanelSettings::get_global(cx);
let visible_worktrees_count =
self.project.read(cx).visible_worktrees(cx).count();
if settings.hide_root && visible_worktrees_count == 1 {
return;
}
}
self.edit_state = Some(EditState {
worktree_id,
entry_id: sub_entry_id,
leaf_entry_id: Some(entry_id),
is_dir: entry.is_dir(),
processing_filename: None,
previously_focused: None,
depth: 0,
validation_state: ValidationState::None,
});
let file_name = entry
.path
.file_name()
.map(|s| s.to_string_lossy())
.unwrap_or_default()
.to_string();
let selection = selection.unwrap_or_else(|| {
let file_stem = entry.path.file_stem().map(|s| s.to_string_lossy());
let selection_end =
file_stem.map_or(file_name.len(), |file_stem| file_stem.len());
0..selection_end
});
self.filename_editor.update(cx, |editor, cx| {
editor.set_text(file_name, window, cx);
editor.change_selections(Default::default(), window, cx, |s| {
s.select_ranges([selection])
});
window.focus(&editor.focus_handle(cx));
});
self.update_visible_entries(None, cx);
self.autoscroll(cx);
cx.notify();
}
self.edit_state = Some(EditState {
worktree_id,
entry_id: sub_entry_id,
leaf_entry_id: Some(entry_id),
is_dir: entry.is_dir(),
processing_filename: None,
previously_focused: None,
depth: 0,
validation_state: ValidationState::None,
});
let file_name = entry
.path
.file_name()
.map(|s| s.to_string_lossy())
.unwrap_or_default()
.to_string();
let selection = selection.unwrap_or_else(|| {
let file_stem = entry.path.file_stem().map(|s| s.to_string_lossy());
let selection_end =
file_stem.map_or(file_name.len(), |file_stem| file_stem.len());
0..selection_end
});
self.filename_editor.update(cx, |editor, cx| {
editor.set_text(file_name, window, cx);
editor.change_selections(Default::default(), window, cx, |s| {
s.select_ranges([selection])
});
window.focus(&editor.focus_handle(cx));
});
self.update_visible_entries(None, cx);
self.autoscroll(cx);
cx.notify();
}
}
}
@ -1820,10 +1814,10 @@ impl ProjectPanel {
};
let next_selection = self.find_next_selection_after_deletion(items_to_delete, cx);
cx.spawn_in(window, async move |panel, cx| {
if let Some(answer) = answer {
if answer.await != Ok(0) {
return anyhow::Ok(());
}
if let Some(answer) = answer
&& answer.await != Ok(0)
{
return anyhow::Ok(());
}
for (entry_id, _) in file_paths {
panel
@ -1988,19 +1982,19 @@ impl ProjectPanel {
}
fn select_next(&mut self, _: &SelectNext, window: &mut Window, cx: &mut Context<Self>) {
if let Some(edit_state) = &self.edit_state {
if edit_state.processing_filename.is_none() {
self.filename_editor.update(cx, |editor, cx| {
editor.move_to_end_of_line(
&editor::actions::MoveToEndOfLine {
stop_at_soft_wraps: false,
},
window,
cx,
);
});
return;
}
if let Some(edit_state) = &self.edit_state
&& edit_state.processing_filename.is_none()
{
self.filename_editor.update(cx, |editor, cx| {
editor.move_to_end_of_line(
&editor::actions::MoveToEndOfLine {
stop_at_soft_wraps: false,
},
window,
cx,
);
});
return;
}
if let Some(selection) = self.selection {
let (mut worktree_ix, mut entry_ix, _) =
@ -2021,20 +2015,19 @@ impl ProjectPanel {
entries,
..
}) = self.visible_entries.get(worktree_ix)
&& let Some(entry) = entries.get(entry_ix)
{
if let Some(entry) = entries.get(entry_ix) {
let selection = SelectedEntry {
worktree_id: *worktree_id,
entry_id: entry.id,
};
self.selection = Some(selection);
if window.modifiers().shift {
self.marked_entries.push(selection);
}
self.autoscroll(cx);
cx.notify();
let selection = SelectedEntry {
worktree_id: *worktree_id,
entry_id: entry.id,
};
self.selection = Some(selection);
if window.modifiers().shift {
self.marked_entries.push(selection);
}
self.autoscroll(cx);
cx.notify();
}
} else {
self.select_first(&SelectFirst {}, window, cx);
@ -2263,19 +2256,18 @@ impl ProjectPanel {
entries,
..
}) = self.visible_entries.first()
&& let Some(entry) = entries.first()
{
if let Some(entry) = entries.first() {
let selection = SelectedEntry {
worktree_id: *worktree_id,
entry_id: entry.id,
};
self.selection = Some(selection);
if window.modifiers().shift {
self.marked_entries.push(selection);
}
self.autoscroll(cx);
cx.notify();
let selection = SelectedEntry {
worktree_id: *worktree_id,
entry_id: entry.id,
};
self.selection = Some(selection);
if window.modifiers().shift {
self.marked_entries.push(selection);
}
self.autoscroll(cx);
cx.notify();
}
}
@ -2936,10 +2928,10 @@ impl ProjectPanel {
let Some(entry) = worktree.entry_for_path(path) else {
continue;
};
if entry.is_dir() {
if let Err(idx) = expanded_dir_ids.binary_search(&entry.id) {
expanded_dir_ids.insert(idx, entry.id);
}
if entry.is_dir()
&& let Err(idx) = expanded_dir_ids.binary_search(&entry.id)
{
expanded_dir_ids.insert(idx, entry.id);
}
}
@ -3013,15 +3005,16 @@ impl ProjectPanel {
let mut new_entry_parent_id = None;
let mut new_entry_kind = EntryKind::Dir;
if let Some(edit_state) = &self.edit_state {
if edit_state.worktree_id == worktree_id && edit_state.is_new_entry() {
new_entry_parent_id = Some(edit_state.entry_id);
new_entry_kind = if edit_state.is_dir {
EntryKind::Dir
} else {
EntryKind::File
};
}
if let Some(edit_state) = &self.edit_state
&& edit_state.worktree_id == worktree_id
&& edit_state.is_new_entry()
{
new_entry_parent_id = Some(edit_state.entry_id);
new_entry_kind = if edit_state.is_dir {
EntryKind::Dir
} else {
EntryKind::File
};
}
let mut visible_worktree_entries = Vec::new();
@ -3032,7 +3025,7 @@ impl ProjectPanel {
if hide_root && Some(entry.entry) == worktree.read(cx).root_entry() {
if new_entry_parent_id == Some(entry.id) {
visible_worktree_entries.push(Self::create_new_git_entry(
&entry.entry,
entry.entry,
entry.git_summary,
new_entry_kind,
));
@ -3043,19 +3036,18 @@ impl ProjectPanel {
}
if auto_collapse_dirs && entry.kind.is_dir() {
auto_folded_ancestors.push(entry.id);
if !self.unfolded_dir_ids.contains(&entry.id) {
if let Some(root_path) = worktree_snapshot.root_entry() {
let mut child_entries = worktree_snapshot.child_entries(&entry.path);
if let Some(child) = child_entries.next() {
if entry.path != root_path.path
&& child_entries.next().is_none()
&& child.kind.is_dir()
{
entry_iter.advance();
if !self.unfolded_dir_ids.contains(&entry.id)
&& let Some(root_path) = worktree_snapshot.root_entry()
{
let mut child_entries = worktree_snapshot.child_entries(&entry.path);
if let Some(child) = child_entries.next()
&& entry.path != root_path.path
&& child_entries.next().is_none()
&& child.kind.is_dir()
{
entry_iter.advance();
continue;
}
}
continue;
}
}
let depth = old_ancestors
@ -3063,10 +3055,10 @@ impl ProjectPanel {
.map(|ancestor| ancestor.current_ancestor_depth)
.unwrap_or_default()
.min(auto_folded_ancestors.len());
if let Some(edit_state) = &mut self.edit_state {
if edit_state.entry_id == entry.id {
edit_state.depth = depth;
}
if let Some(edit_state) = &mut self.edit_state
&& edit_state.entry_id == entry.id
{
edit_state.depth = depth;
}
let mut ancestors = std::mem::take(&mut auto_folded_ancestors);
if ancestors.len() > 1 {
@ -3088,14 +3080,14 @@ impl ProjectPanel {
entry.id == new_entry_id || {
self.ancestors
.get(&entry.id)
.map_or(false, |entries| entries.ancestors.contains(&new_entry_id))
.is_some_and(|entries| entries.ancestors.contains(&new_entry_id))
}
} else {
false
};
if precedes_new_entry && (!hide_gitignore || !entry.is_ignored) {
visible_worktree_entries.push(Self::create_new_git_entry(
&entry.entry,
entry.entry,
entry.git_summary,
new_entry_kind,
));
@ -3303,11 +3295,10 @@ impl ProjectPanel {
)
})?.await?;
if answer == 1 {
if let Some(item_idx) = paths.iter().position(|p| p == original_path) {
if answer == 1
&& let Some(item_idx) = paths.iter().position(|p| p == original_path) {
paths.remove(item_idx);
}
}
}
if paths.is_empty() {
@ -3492,7 +3483,7 @@ impl ProjectPanel {
let base_index = ix + entry_range.start;
for (i, entry) in visible.entries[entry_range].iter().enumerate() {
let global_index = base_index + i;
callback(&entry, global_index, entries, window, cx);
callback(entry, global_index, entries, window, cx);
}
ix = end_ix;
}
@ -3587,7 +3578,7 @@ impl ProjectPanel {
previous_components.next();
}
if let Some(_) = suffix_components {
if suffix_components.is_some() {
new_path.push(previous_components);
}
if let Some(str) = new_path.to_str() {
@ -3972,7 +3963,7 @@ impl ProjectPanel {
let is_marked = self.marked_entries.contains(&selection);
let is_active = self
.selection
.map_or(false, |selection| selection.entry_id == entry_id);
.is_some_and(|selection| selection.entry_id == entry_id);
let file_name = details.filename.clone();
@ -4179,7 +4170,7 @@ impl ProjectPanel {
|| this
.expanded_dir_ids
.get(&details.worktree_id)
.map_or(false, |ids| ids.binary_search(&entry_id).is_ok())
.is_some_and(|ids| ids.binary_search(&entry_id).is_ok())
{
return;
}
@ -4298,8 +4289,8 @@ impl ProjectPanel {
}
} else if kind.is_dir() {
project_panel.marked_entries.clear();
if is_sticky {
if let Some((_, _, index)) = project_panel.index_for_entry(entry_id, worktree_id) {
if is_sticky
&& let Some((_, _, index)) = project_panel.index_for_entry(entry_id, worktree_id) {
project_panel.scroll_handle.scroll_to_item_with_offset(index, ScrollStrategy::Top, sticky_index.unwrap_or(0));
cx.notify();
// move down by 1px so that clicked item
@ -4314,7 +4305,6 @@ impl ProjectPanel {
});
return;
}
}
if event.modifiers().alt {
project_panel.toggle_expand_all(entry_id, window, cx);
} else {
@ -4400,19 +4390,17 @@ impl ProjectPanel {
} else {
h_flex().child(Icon::from_path(icon.to_string()).color(Color::Muted))
}
} else if let Some((icon_name, color)) =
entry_diagnostic_aware_icon_name_and_color(diagnostic_severity)
{
h_flex()
.size(IconSize::default().rems())
.child(Icon::new(icon_name).color(color).size(IconSize::Small))
} else {
if let Some((icon_name, color)) =
entry_diagnostic_aware_icon_name_and_color(diagnostic_severity)
{
h_flex()
.size(IconSize::default().rems())
.child(Icon::new(icon_name).color(color).size(IconSize::Small))
} else {
h_flex()
.size(IconSize::default().rems())
.invisible()
.flex_none()
}
h_flex()
.size(IconSize::default().rems())
.invisible()
.flex_none()
})
.child(
if let (Some(editor), true) = (Some(&self.filename_editor), show_editor) {
@ -4423,9 +4411,7 @@ impl ProjectPanel {
let components = Path::new(&file_name)
.components()
.map(|comp| {
let comp_str =
comp.as_os_str().to_string_lossy().into_owned();
comp_str
comp.as_os_str().to_string_lossy().into_owned()
})
.collect::<Vec<_>>();
@ -4464,7 +4450,7 @@ impl ProjectPanel {
);
} else {
let is_current_target = this.folded_directory_drag_target
.map_or(false, |target|
.is_some_and(|target|
target.entry_id == entry_id &&
target.index == delimiter_target_index &&
target.is_delimiter_target
@ -4508,7 +4494,7 @@ impl ProjectPanel {
} else {
let is_current_target = this.folded_directory_drag_target
.as_ref()
.map_or(false, |target|
.is_some_and(|target|
target.entry_id == entry_id &&
target.index == index &&
!target.is_delimiter_target
@ -4527,7 +4513,7 @@ impl ProjectPanel {
this.drag_onto(selections, target_entry_id, kind.is_file(), window, cx);
}
}))
.when(folded_directory_drag_target.map_or(false, |target|
.when(folded_directory_drag_target.is_some_and(|target|
target.entry_id == entry_id &&
target.index == index
), |this| {
@ -4536,15 +4522,14 @@ impl ProjectPanel {
})
})
.on_click(cx.listener(move |this, _, _, cx| {
if index != active_index {
if let Some(folds) =
if index != active_index
&& let Some(folds) =
this.ancestors.get_mut(&entry_id)
{
folds.current_ancestor_depth =
components_len - 1 - index;
cx.notify();
}
}
}))
.child(
Label::new(component)
@ -4658,7 +4643,7 @@ impl ProjectPanel {
};
let (depth, difference) =
ProjectPanel::calculate_depth_and_difference(&entry, entries_paths);
ProjectPanel::calculate_depth_and_difference(entry, entries_paths);
let filename = match difference {
diff if diff > 1 => entry
@ -4694,7 +4679,7 @@ impl ProjectPanel {
let is_cut = self
.clipboard
.as_ref()
.map_or(false, |e| e.is_cut() && e.items().contains(&selection));
.is_some_and(|e| e.is_cut() && e.items().contains(&selection));
EntryDetails {
filename,
@ -4749,7 +4734,7 @@ impl ProjectPanel {
if skip_ignored
&& worktree
.entry_for_id(entry_id)
.map_or(true, |entry| entry.is_ignored && !entry.is_always_included)
.is_none_or(|entry| entry.is_ignored && !entry.is_always_included)
{
anyhow::bail!("can't reveal an ignored entry in the project panel");
}
@ -4880,12 +4865,12 @@ impl ProjectPanel {
'outer: loop {
if let Some(parent_path) = current_path.parent() {
for ancestor_path in parent_path.ancestors() {
if paths.contains(ancestor_path) {
if let Some(parent_entry) = worktree.entry_for_path(ancestor_path) {
sticky_parents.push(parent_entry.clone());
current_path = parent_entry.path.clone();
continue 'outer;
}
if paths.contains(ancestor_path)
&& let Some(parent_entry) = worktree.entry_for_path(ancestor_path)
{
sticky_parents.push(parent_entry.clone());
current_path = parent_entry.path.clone();
continue 'outer;
}
}
}
@ -5128,25 +5113,25 @@ impl Render for ProjectPanel {
.on_action(cx.listener(Self::paste))
.on_action(cx.listener(Self::duplicate))
.on_click(cx.listener(|this, event: &gpui::ClickEvent, window, cx| {
if event.click_count() > 1 {
if let Some(entry_id) = this.last_worktree_root_id {
let project = this.project.read(cx);
if event.click_count() > 1
&& let Some(entry_id) = this.last_worktree_root_id
{
let project = this.project.read(cx);
let worktree_id = if let Some(worktree) =
project.worktree_for_entry(entry_id, cx)
{
worktree.read(cx).id()
} else {
return;
};
let worktree_id = if let Some(worktree) =
project.worktree_for_entry(entry_id, cx)
{
worktree.read(cx).id()
} else {
return;
};
this.selection = Some(SelectedEntry {
worktree_id,
entry_id,
});
this.selection = Some(SelectedEntry {
worktree_id,
entry_id,
});
this.new_file(&NewFile, window, cx);
}
this.new_file(&NewFile, window, cx);
}
}))
})
@ -5539,7 +5524,7 @@ impl Panel for ProjectPanel {
project.visible_worktrees(cx).any(|tree| {
tree.read(cx)
.root_entry()
.map_or(false, |entry| entry.is_dir())
.is_some_and(|entry| entry.is_dir())
})
}