Fix a bunch of other low-hanging style lints (#36498)
- **Fix a bunch of low hanging style lints like unnecessary-return** - **Fix single worktree violation** - **And the rest** Release Notes: - N/A
This commit is contained in:
parent
df9c2aefb1
commit
05fc0c432c
239 changed files with 854 additions and 1015 deletions
|
@ -460,7 +460,7 @@ impl Dock {
|
|||
};
|
||||
|
||||
let was_visible = this.is_open()
|
||||
&& this.visible_panel().map_or(false, |active_panel| {
|
||||
&& this.visible_panel().is_some_and(|active_panel| {
|
||||
active_panel.panel_id() == Entity::entity_id(&panel)
|
||||
});
|
||||
|
||||
|
@ -523,7 +523,7 @@ impl Dock {
|
|||
PanelEvent::Close => {
|
||||
if this
|
||||
.visible_panel()
|
||||
.map_or(false, |p| p.panel_id() == Entity::entity_id(panel))
|
||||
.is_some_and(|p| p.panel_id() == Entity::entity_id(panel))
|
||||
{
|
||||
this.set_open(false, window, cx);
|
||||
}
|
||||
|
|
|
@ -489,7 +489,7 @@ where
|
|||
fn should_serialize(&self, event: &dyn Any, cx: &App) -> bool {
|
||||
event
|
||||
.downcast_ref::<T::Event>()
|
||||
.map_or(false, |event| self.read(cx).should_serialize(event))
|
||||
.is_some_and(|event| self.read(cx).should_serialize(event))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -552,9 +552,9 @@ impl Pane {
|
|||
// to the item, and `focus_handle.contains_focus` returns false because the `active_item`
|
||||
// is not hooked up to us in the dispatch tree.
|
||||
self.focus_handle.contains_focused(window, cx)
|
||||
|| self.active_item().map_or(false, |item| {
|
||||
item.item_focus_handle(cx).contains_focused(window, cx)
|
||||
})
|
||||
|| self
|
||||
.active_item()
|
||||
.is_some_and(|item| item.item_focus_handle(cx).contains_focused(window, cx))
|
||||
}
|
||||
|
||||
fn focus_in(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
|
@ -1021,7 +1021,7 @@ impl Pane {
|
|||
existing_item
|
||||
.project_entry_ids(cx)
|
||||
.first()
|
||||
.map_or(false, |existing_entry_id| {
|
||||
.is_some_and(|existing_entry_id| {
|
||||
Some(existing_entry_id) == project_entry_id.as_ref()
|
||||
})
|
||||
} else {
|
||||
|
@ -1558,7 +1558,7 @@ impl Pane {
|
|||
let other_project_item_ids = open_item.project_item_model_ids(cx);
|
||||
dirty_project_item_ids.retain(|id| !other_project_item_ids.contains(id));
|
||||
}
|
||||
return dirty_project_item_ids.is_empty();
|
||||
dirty_project_item_ids.is_empty()
|
||||
}
|
||||
|
||||
pub(super) fn file_names_for_prompt(
|
||||
|
@ -2745,7 +2745,7 @@ impl Pane {
|
|||
worktree
|
||||
.read(cx)
|
||||
.root_entry()
|
||||
.map_or(false, |entry| entry.is_dir())
|
||||
.is_some_and(|entry| entry.is_dir())
|
||||
});
|
||||
|
||||
let entry_abs_path = pane.read(cx).entry_abs_path(entry, cx);
|
||||
|
@ -3210,8 +3210,7 @@ impl Pane {
|
|||
return;
|
||||
};
|
||||
|
||||
if target.map_or(false, |target| this.is_tab_pinned(target))
|
||||
{
|
||||
if target.is_some_and(|target| this.is_tab_pinned(target)) {
|
||||
this.pin_tab_at(index, window, cx);
|
||||
}
|
||||
})
|
||||
|
@ -3615,7 +3614,6 @@ impl Render for Pane {
|
|||
)
|
||||
.on_action(cx.listener(|_, _: &menu::Cancel, window, cx| {
|
||||
if cx.stop_active_drag(window) {
|
||||
return;
|
||||
} else {
|
||||
cx.propagate();
|
||||
}
|
||||
|
|
|
@ -1804,7 +1804,7 @@ impl Workspace {
|
|||
.max_by(|b1, b2| b1.worktree_id.cmp(&b2.worktree_id))
|
||||
});
|
||||
|
||||
latest_project_path_opened.map_or(true, |path| path == history_path)
|
||||
latest_project_path_opened.is_none_or(|path| path == history_path)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2284,7 +2284,7 @@ impl Workspace {
|
|||
// the current session.
|
||||
if close_intent != CloseIntent::Quit
|
||||
&& !save_last_workspace
|
||||
&& save_result.as_ref().map_or(false, |&res| res)
|
||||
&& save_result.as_ref().is_ok_and(|&res| res)
|
||||
{
|
||||
this.update_in(cx, |this, window, cx| this.remove_from_session(window, cx))?
|
||||
.await;
|
||||
|
@ -5133,13 +5133,11 @@ impl Workspace {
|
|||
self.panes.retain(|p| p != pane);
|
||||
if let Some(focus_on) = focus_on {
|
||||
focus_on.update(cx, |pane, cx| window.focus(&pane.focus_handle(cx)));
|
||||
} else {
|
||||
if self.active_pane() == pane {
|
||||
self.panes
|
||||
.last()
|
||||
.unwrap()
|
||||
.update(cx, |pane, cx| window.focus(&pane.focus_handle(cx)));
|
||||
}
|
||||
} else if self.active_pane() == pane {
|
||||
self.panes
|
||||
.last()
|
||||
.unwrap()
|
||||
.update(cx, |pane, cx| window.focus(&pane.focus_handle(cx)));
|
||||
}
|
||||
if self.last_active_center_pane == Some(pane.downgrade()) {
|
||||
self.last_active_center_pane = None;
|
||||
|
@ -5893,7 +5891,6 @@ impl Workspace {
|
|||
|
||||
pub fn cancel(&mut self, _: &menu::Cancel, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if cx.stop_active_drag(window) {
|
||||
return;
|
||||
} else if let Some((notification_id, _)) = self.notifications.pop() {
|
||||
dismiss_app_notification(¬ification_id, cx);
|
||||
} else {
|
||||
|
@ -6100,7 +6097,7 @@ fn open_items(
|
|||
// here is a directory, it was already opened further above
|
||||
// with a `find_or_create_worktree`.
|
||||
if let Ok(task) = abs_path_task
|
||||
&& task.await.map_or(true, |p| p.is_file())
|
||||
&& task.await.is_none_or(|p| p.is_file())
|
||||
{
|
||||
return Some((
|
||||
ix,
|
||||
|
@ -6970,7 +6967,7 @@ async fn join_channel_internal(
|
|||
&& 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())
|
||||
})
|
||||
{
|
||||
Some(workspace.project.clone())
|
||||
|
@ -7900,7 +7897,6 @@ fn join_pane_into_active(
|
|||
cx: &mut App,
|
||||
) {
|
||||
if pane == active_pane {
|
||||
return;
|
||||
} else if pane.read(cx).items_len() == 0 {
|
||||
pane.update(cx, |_, cx| {
|
||||
cx.emit(pane::Event::Remove {
|
||||
|
@ -9149,11 +9145,11 @@ mod tests {
|
|||
workspace.update_in(cx, |workspace, window, cx| {
|
||||
workspace.add_item_to_active_pane(Box::new(item.clone()), None, false, window, cx);
|
||||
});
|
||||
return item;
|
||||
item
|
||||
}
|
||||
|
||||
fn split_pane(cx: &mut VisualTestContext, workspace: &Entity<Workspace>) -> Entity<Pane> {
|
||||
return workspace.update_in(cx, |workspace, window, cx| {
|
||||
workspace.update_in(cx, |workspace, window, cx| {
|
||||
let new_pane = workspace.split_pane(
|
||||
workspace.active_pane().clone(),
|
||||
SplitDirection::Right,
|
||||
|
@ -9161,7 +9157,7 @@ mod tests {
|
|||
cx,
|
||||
);
|
||||
new_pane
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue