Auto-fix clippy::collapsible_if violations (#36428)
Release Notes: - N/A
This commit is contained in:
parent
9e8ec72bd5
commit
8f567383e4
281 changed files with 6628 additions and 7089 deletions
|
@ -1170,12 +1170,11 @@ impl OutlinePanel {
|
|||
});
|
||||
} else {
|
||||
let mut offset = Point::default();
|
||||
if let Some(buffer_id) = scroll_to_buffer {
|
||||
if multi_buffer_snapshot.as_singleton().is_none()
|
||||
&& !active_editor.read(cx).is_buffer_folded(buffer_id, cx)
|
||||
{
|
||||
offset.y = -(active_editor.read(cx).file_header_size() as f32);
|
||||
}
|
||||
if let Some(buffer_id) = scroll_to_buffer
|
||||
&& multi_buffer_snapshot.as_singleton().is_none()
|
||||
&& !active_editor.read(cx).is_buffer_folded(buffer_id, cx)
|
||||
{
|
||||
offset.y = -(active_editor.read(cx).file_header_size() as f32);
|
||||
}
|
||||
|
||||
active_editor.update(cx, |editor, cx| {
|
||||
|
@ -1606,16 +1605,14 @@ impl OutlinePanel {
|
|||
}
|
||||
PanelEntry::FoldedDirs(folded_dirs) => {
|
||||
let mut folded = false;
|
||||
if let Some(dir_entry) = folded_dirs.entries.last() {
|
||||
if self
|
||||
if let Some(dir_entry) = folded_dirs.entries.last()
|
||||
&& self
|
||||
.collapsed_entries
|
||||
.insert(CollapsedEntry::Dir(folded_dirs.worktree_id, dir_entry.id))
|
||||
{
|
||||
folded = true;
|
||||
buffers_to_fold.extend(
|
||||
self.buffers_inside_directory(folded_dirs.worktree_id, dir_entry),
|
||||
);
|
||||
}
|
||||
{
|
||||
folded = true;
|
||||
buffers_to_fold
|
||||
.extend(self.buffers_inside_directory(folded_dirs.worktree_id, dir_entry));
|
||||
}
|
||||
folded
|
||||
}
|
||||
|
@ -2108,11 +2105,11 @@ impl OutlinePanel {
|
|||
dirs_to_expand.push(current_entry.id);
|
||||
}
|
||||
|
||||
if traversal.back_to_parent() {
|
||||
if let Some(parent_entry) = traversal.entry() {
|
||||
current_entry = parent_entry.clone();
|
||||
continue;
|
||||
}
|
||||
if traversal.back_to_parent()
|
||||
&& let Some(parent_entry) = traversal.entry()
|
||||
{
|
||||
current_entry = parent_entry.clone();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2475,17 +2472,17 @@ impl OutlinePanel {
|
|||
let search_data = match render_data.get() {
|
||||
Some(search_data) => search_data,
|
||||
None => {
|
||||
if let ItemsDisplayMode::Search(search_state) = &mut self.mode {
|
||||
if let Some(multi_buffer_snapshot) = multi_buffer_snapshot {
|
||||
search_state
|
||||
.highlight_search_match_tx
|
||||
.try_send(HighlightArguments {
|
||||
multi_buffer_snapshot: multi_buffer_snapshot.clone(),
|
||||
match_range: match_range.clone(),
|
||||
search_data: Arc::clone(render_data),
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
if let ItemsDisplayMode::Search(search_state) = &mut self.mode
|
||||
&& let Some(multi_buffer_snapshot) = multi_buffer_snapshot
|
||||
{
|
||||
search_state
|
||||
.highlight_search_match_tx
|
||||
.try_send(HighlightArguments {
|
||||
multi_buffer_snapshot: multi_buffer_snapshot.clone(),
|
||||
match_range: match_range.clone(),
|
||||
search_data: Arc::clone(render_data),
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
@ -2833,11 +2830,12 @@ impl OutlinePanel {
|
|||
let new_entry_added = entries_to_add
|
||||
.insert(current_entry.id, current_entry)
|
||||
.is_none();
|
||||
if new_entry_added && traversal.back_to_parent() {
|
||||
if let Some(parent_entry) = traversal.entry() {
|
||||
current_entry = parent_entry.to_owned();
|
||||
continue;
|
||||
}
|
||||
if new_entry_added
|
||||
&& traversal.back_to_parent()
|
||||
&& let Some(parent_entry) = traversal.entry()
|
||||
{
|
||||
current_entry = parent_entry.to_owned();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2878,18 +2876,17 @@ impl OutlinePanel {
|
|||
entries
|
||||
.into_iter()
|
||||
.filter_map(|entry| {
|
||||
if auto_fold_dirs {
|
||||
if let Some(parent) = entry.path.parent() {
|
||||
let children = new_children_count
|
||||
.entry(worktree_id)
|
||||
.or_default()
|
||||
.entry(Arc::from(parent))
|
||||
.or_default();
|
||||
if entry.is_dir() {
|
||||
children.dirs += 1;
|
||||
} else {
|
||||
children.files += 1;
|
||||
}
|
||||
if auto_fold_dirs && let Some(parent) = entry.path.parent()
|
||||
{
|
||||
let children = new_children_count
|
||||
.entry(worktree_id)
|
||||
.or_default()
|
||||
.entry(Arc::from(parent))
|
||||
.or_default();
|
||||
if entry.is_dir() {
|
||||
children.dirs += 1;
|
||||
} else {
|
||||
children.files += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3409,30 +3406,29 @@ impl OutlinePanel {
|
|||
{
|
||||
excerpt.outlines = ExcerptOutlines::Outlines(fetched_outlines);
|
||||
|
||||
if let Some(default_depth) = pending_default_depth {
|
||||
if let ExcerptOutlines::Outlines(outlines) =
|
||||
if let Some(default_depth) = pending_default_depth
|
||||
&& let ExcerptOutlines::Outlines(outlines) =
|
||||
&excerpt.outlines
|
||||
{
|
||||
outlines
|
||||
.iter()
|
||||
.filter(|outline| {
|
||||
(default_depth == 0
|
||||
|| outline.depth >= default_depth)
|
||||
&& outlines_with_children.contains(&(
|
||||
outline.range.clone(),
|
||||
outline.depth,
|
||||
))
|
||||
})
|
||||
.for_each(|outline| {
|
||||
outline_panel.collapsed_entries.insert(
|
||||
CollapsedEntry::Outline(
|
||||
buffer_id,
|
||||
excerpt_id,
|
||||
outline.range.clone(),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
{
|
||||
outlines
|
||||
.iter()
|
||||
.filter(|outline| {
|
||||
(default_depth == 0
|
||||
|| outline.depth >= default_depth)
|
||||
&& outlines_with_children.contains(&(
|
||||
outline.range.clone(),
|
||||
outline.depth,
|
||||
))
|
||||
})
|
||||
.for_each(|outline| {
|
||||
outline_panel.collapsed_entries.insert(
|
||||
CollapsedEntry::Outline(
|
||||
buffer_id,
|
||||
excerpt_id,
|
||||
outline.range.clone(),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Even if no outlines to check, we still need to update cached entries
|
||||
|
@ -3611,10 +3607,9 @@ impl OutlinePanel {
|
|||
.update_in(cx, |outline_panel, window, cx| {
|
||||
outline_panel.cached_entries = new_cached_entries;
|
||||
outline_panel.max_width_item_index = max_width_item_index;
|
||||
if outline_panel.selected_entry.is_invalidated()
|
||||
|| matches!(outline_panel.selected_entry, SelectedEntry::None)
|
||||
{
|
||||
if let Some(new_selected_entry) =
|
||||
if (outline_panel.selected_entry.is_invalidated()
|
||||
|| matches!(outline_panel.selected_entry, SelectedEntry::None))
|
||||
&& let Some(new_selected_entry) =
|
||||
outline_panel.active_editor().and_then(|active_editor| {
|
||||
outline_panel.location_for_editor_selection(
|
||||
&active_editor,
|
||||
|
@ -3622,9 +3617,8 @@ impl OutlinePanel {
|
|||
cx,
|
||||
)
|
||||
})
|
||||
{
|
||||
outline_panel.select_entry(new_selected_entry, false, window, cx);
|
||||
}
|
||||
{
|
||||
outline_panel.select_entry(new_selected_entry, false, window, cx);
|
||||
}
|
||||
|
||||
outline_panel.autoscroll(cx);
|
||||
|
@ -3921,19 +3915,19 @@ impl OutlinePanel {
|
|||
} else {
|
||||
None
|
||||
};
|
||||
if let Some((buffer_id, entry_excerpts)) = excerpts_to_consider {
|
||||
if !active_editor.read(cx).is_buffer_folded(buffer_id, cx) {
|
||||
outline_panel.add_excerpt_entries(
|
||||
&mut generation_state,
|
||||
buffer_id,
|
||||
entry_excerpts,
|
||||
depth,
|
||||
track_matches,
|
||||
is_singleton,
|
||||
query.as_deref(),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
if let Some((buffer_id, entry_excerpts)) = excerpts_to_consider
|
||||
&& !active_editor.read(cx).is_buffer_folded(buffer_id, cx)
|
||||
{
|
||||
outline_panel.add_excerpt_entries(
|
||||
&mut generation_state,
|
||||
buffer_id,
|
||||
entry_excerpts,
|
||||
depth,
|
||||
track_matches,
|
||||
is_singleton,
|
||||
query.as_deref(),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4404,15 +4398,15 @@ impl OutlinePanel {
|
|||
})
|
||||
.filter(|(match_range, _)| {
|
||||
let editor = active_editor.read(cx);
|
||||
if let Some(buffer_id) = match_range.start.buffer_id {
|
||||
if editor.is_buffer_folded(buffer_id, cx) {
|
||||
return false;
|
||||
}
|
||||
if let Some(buffer_id) = match_range.start.buffer_id
|
||||
&& editor.is_buffer_folded(buffer_id, cx)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if let Some(buffer_id) = match_range.start.buffer_id {
|
||||
if editor.is_buffer_folded(buffer_id, cx) {
|
||||
return false;
|
||||
}
|
||||
if let Some(buffer_id) = match_range.start.buffer_id
|
||||
&& editor.is_buffer_folded(buffer_id, cx)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
true
|
||||
});
|
||||
|
@ -4456,16 +4450,14 @@ impl OutlinePanel {
|
|||
cx: &mut Context<Self>,
|
||||
) {
|
||||
self.pinned = !self.pinned;
|
||||
if !self.pinned {
|
||||
if let Some((active_item, active_editor)) = self
|
||||
if !self.pinned
|
||||
&& let Some((active_item, active_editor)) = self
|
||||
.workspace
|
||||
.upgrade()
|
||||
.and_then(|workspace| workspace_active_editor(workspace.read(cx), cx))
|
||||
{
|
||||
if self.should_replace_active_item(active_item.as_ref()) {
|
||||
self.replace_active_editor(active_item, active_editor, window, cx);
|
||||
}
|
||||
}
|
||||
&& self.should_replace_active_item(active_item.as_ref())
|
||||
{
|
||||
self.replace_active_editor(active_item, active_editor, window, cx);
|
||||
}
|
||||
|
||||
cx.notify();
|
||||
|
@ -5067,24 +5059,23 @@ impl Panel for OutlinePanel {
|
|||
let old_active = outline_panel.active;
|
||||
outline_panel.active = active;
|
||||
if old_active != active {
|
||||
if active {
|
||||
if let Some((active_item, active_editor)) =
|
||||
if active
|
||||
&& let Some((active_item, active_editor)) =
|
||||
outline_panel.workspace.upgrade().and_then(|workspace| {
|
||||
workspace_active_editor(workspace.read(cx), cx)
|
||||
})
|
||||
{
|
||||
if outline_panel.should_replace_active_item(active_item.as_ref()) {
|
||||
outline_panel.replace_active_editor(
|
||||
active_item,
|
||||
active_editor,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
} else {
|
||||
outline_panel.update_fs_entries(active_editor, None, window, cx)
|
||||
}
|
||||
return;
|
||||
{
|
||||
if outline_panel.should_replace_active_item(active_item.as_ref()) {
|
||||
outline_panel.replace_active_editor(
|
||||
active_item,
|
||||
active_editor,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
} else {
|
||||
outline_panel.update_fs_entries(active_editor, None, window, cx)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if !outline_panel.pinned {
|
||||
|
@ -5319,8 +5310,8 @@ fn subscribe_for_editor_events(
|
|||
})
|
||||
.copied(),
|
||||
);
|
||||
if !ignore_selections_change {
|
||||
if let Some(entry_to_select) = latest_unfolded_buffer_id
|
||||
if !ignore_selections_change
|
||||
&& let Some(entry_to_select) = latest_unfolded_buffer_id
|
||||
.or(latest_folded_buffer_id)
|
||||
.and_then(|toggled_buffer_id| {
|
||||
outline_panel.fs_entries.iter().find_map(
|
||||
|
@ -5344,9 +5335,8 @@ fn subscribe_for_editor_events(
|
|||
)
|
||||
})
|
||||
.map(PanelEntry::Fs)
|
||||
{
|
||||
outline_panel.select_entry(entry_to_select, true, window, cx);
|
||||
}
|
||||
{
|
||||
outline_panel.select_entry(entry_to_select, true, window, cx);
|
||||
}
|
||||
|
||||
outline_panel.update_fs_entries(editor.clone(), debounce, window, cx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue