One big cleanup pass of clippy lints
Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
e7540d2833
commit
8ba2f77148
138 changed files with 1328 additions and 1366 deletions
|
@ -189,7 +189,7 @@ pub struct NavigationEntry {
|
|||
impl Pane {
|
||||
pub fn new(cx: &mut ViewContext<Self>) -> Self {
|
||||
let handle = cx.weak_handle();
|
||||
let context_menu = cx.add_view(|cx| ContextMenu::new(cx));
|
||||
let context_menu = cx.add_view(ContextMenu::new);
|
||||
Self {
|
||||
items: Vec::new(),
|
||||
is_active: true,
|
||||
|
@ -389,7 +389,7 @@ impl Pane {
|
|||
let existing_item = pane.update(cx, |pane, cx| {
|
||||
for (ix, item) in pane.items.iter().enumerate() {
|
||||
if item.project_path(cx).is_some()
|
||||
&& item.project_entry_ids(cx).as_slice() == &[project_entry_id]
|
||||
&& item.project_entry_ids(cx).as_slice() == [project_entry_id]
|
||||
{
|
||||
let item = item.boxed_clone();
|
||||
pane.activate_item(ix, true, focus_item, true, cx);
|
||||
|
@ -450,7 +450,7 @@ impl Pane {
|
|||
self.items.iter()
|
||||
}
|
||||
|
||||
pub fn items_of_type<'a, T: View>(&'a self) -> impl 'a + Iterator<Item = ViewHandle<T>> {
|
||||
pub fn items_of_type<T: View>(&self) -> impl '_ + Iterator<Item = ViewHandle<T>> {
|
||||
self.items
|
||||
.iter()
|
||||
.filter_map(|item| item.to_any().downcast())
|
||||
|
@ -466,7 +466,7 @@ impl Pane {
|
|||
cx: &AppContext,
|
||||
) -> Option<Box<dyn ItemHandle>> {
|
||||
self.items.iter().find_map(|item| {
|
||||
if item.is_singleton(cx) && item.project_entry_ids(cx).as_slice() == &[entry_id] {
|
||||
if item.is_singleton(cx) && item.project_entry_ids(cx).as_slice() == [entry_id] {
|
||||
Some(item.boxed_clone())
|
||||
} else {
|
||||
None
|
||||
|
@ -532,7 +532,7 @@ impl Pane {
|
|||
let mut index = self.active_item_index;
|
||||
if index > 0 {
|
||||
index -= 1;
|
||||
} else if self.items.len() > 0 {
|
||||
} else if !self.items.is_empty() {
|
||||
index = self.items.len() - 1;
|
||||
}
|
||||
self.activate_item(index, true, true, false, cx);
|
||||
|
@ -653,7 +653,7 @@ impl Pane {
|
|||
{
|
||||
let other_project_entry_ids = item.project_entry_ids(cx);
|
||||
project_entry_ids
|
||||
.retain(|id| !other_project_entry_ids.contains(&id));
|
||||
.retain(|id| !other_project_entry_ids.contains(id));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -662,12 +662,11 @@ impl Pane {
|
|||
.any(|id| saved_project_entry_ids.insert(*id))
|
||||
};
|
||||
|
||||
if should_save {
|
||||
if !Self::save_item(project.clone(), &pane, item_ix, &item, true, &mut cx)
|
||||
if should_save
|
||||
&& !Self::save_item(project.clone(), &pane, item_ix, &*item, true, &mut cx)
|
||||
.await?
|
||||
{
|
||||
break;
|
||||
}
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// Remove the item from the pane.
|
||||
|
@ -728,14 +727,13 @@ impl Pane {
|
|||
project: ModelHandle<Project>,
|
||||
pane: &ViewHandle<Pane>,
|
||||
item_ix: usize,
|
||||
item: &Box<dyn ItemHandle>,
|
||||
item: &dyn ItemHandle,
|
||||
should_prompt_for_save: bool,
|
||||
cx: &mut AsyncAppContext,
|
||||
) -> Result<bool> {
|
||||
const CONFLICT_MESSAGE: &'static str =
|
||||
const CONFLICT_MESSAGE: &str =
|
||||
"This file has changed on disk since you started editing it. Do you want to overwrite it?";
|
||||
const DIRTY_MESSAGE: &'static str =
|
||||
"This file contains unsaved edits. Do you want to save it?";
|
||||
const DIRTY_MESSAGE: &str = "This file contains unsaved edits. Do you want to save it?";
|
||||
|
||||
let (has_conflict, is_dirty, can_save, is_singleton) = cx.read(|cx| {
|
||||
(
|
||||
|
@ -765,7 +763,7 @@ impl Pane {
|
|||
matches!(
|
||||
cx.global::<Settings>().autosave,
|
||||
Autosave::OnFocusChange | Autosave::OnWindowChange
|
||||
) && Self::can_autosave_item(item.as_ref(), cx)
|
||||
) && Self::can_autosave_item(&*item, cx)
|
||||
});
|
||||
let should_save = if should_prompt_for_save && !will_autosave {
|
||||
let mut answer = pane.update(cx, |pane, cx| {
|
||||
|
@ -794,7 +792,7 @@ impl Pane {
|
|||
let worktree = project.visible_worktrees(cx).next()?;
|
||||
Some(worktree.read(cx).as_local()?.abs_path().to_path_buf())
|
||||
})
|
||||
.unwrap_or(Path::new("").into());
|
||||
.unwrap_or_else(|| Path::new("").into());
|
||||
|
||||
let mut abs_path = cx.update(|cx| cx.prompt_for_new_path(&start_abs_path));
|
||||
if let Some(abs_path) = abs_path.next().await.flatten() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue