chore: Fix several style lints (#17488)

It's not comprehensive enough to start linting on `style` group, but
hey, it's a start.

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-09-06 11:58:39 +02:00 committed by GitHub
parent 93249fc82b
commit e6c1c51b37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
361 changed files with 3530 additions and 3587 deletions

View file

@ -235,7 +235,7 @@ impl ProjectPanel {
})
.detach();
let filename_editor = cx.new_view(|cx| Editor::single_line(cx));
let filename_editor = cx.new_view(Editor::single_line);
cx.subscribe(&filename_editor, |this, _, event, cx| match event {
editor::EditorEvent::BufferEdited
@ -557,7 +557,7 @@ impl ProjectPanel {
if let Some(parent_path) = entry.path.parent() {
let snapshot = worktree.snapshot();
let mut child_entries = snapshot.child_entries(&parent_path);
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();
@ -758,7 +758,7 @@ impl ProjectPanel {
worktree_id,
entry_id: NEW_ENTRY_ID,
});
let new_path = entry.path.join(&filename.trim_start_matches('/'));
let new_path = entry.path.join(filename.trim_start_matches('/'));
if path_already_exists(new_path.as_path()) {
return None;
}
@ -1537,7 +1537,6 @@ impl ProjectPanel {
.move_worktree(worktree_id, destination_id, cx)
.log_err();
});
return;
}
fn move_worktree_entry(
@ -1652,8 +1651,7 @@ impl ProjectPanel {
let project = self.project.read(cx);
self.last_worktree_root_id = project
.visible_worktrees(cx)
.rev()
.next()
.next_back()
.and_then(|worktree| worktree.read(cx).root_entry())
.map(|entry| entry.id);
@ -1794,10 +1792,7 @@ impl ProjectPanel {
entry_id: ProjectEntryId,
cx: &mut ViewContext<Self>,
) {
let mut paths: Vec<Arc<Path>> = paths
.into_iter()
.map(|path| Arc::from(path.clone()))
.collect();
let mut paths: Vec<Arc<Path>> = paths.iter().map(|path| Arc::from(path.clone())).collect();
let open_file_after_drop = paths.len() == 1 && paths[0].is_file();
@ -1882,7 +1877,7 @@ impl ProjectPanel {
.clone();
for selection in selections.items() {
let new_path = self.create_paste_path(
&selection,
selection,
(target_worktree.clone(), &target_entry),
cx,
)?;
@ -1945,7 +1940,7 @@ impl ProjectPanel {
.collect()
});
for entry in visible_worktree_entries[entry_range].iter() {
let status = git_status_setting.then(|| entry.git_status).flatten();
let status = git_status_setting.then_some(entry.git_status).flatten();
let is_expanded = expanded_entry_ids.binary_search(&entry.id).is_ok();
let icon = match entry.kind {
EntryKind::File => {
@ -1965,7 +1960,7 @@ impl ProjectPanel {
};
let (depth, difference) =
ProjectPanel::calculate_depth_and_difference(entry, &entries);
ProjectPanel::calculate_depth_and_difference(entry, entries);
let filename = match difference {
diff if diff > 1 => entry
@ -2463,7 +2458,7 @@ impl ProjectPanel {
impl Render for ProjectPanel {
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl IntoElement {
let has_worktree = self.visible_entries.len() != 0;
let has_worktree = !self.visible_entries.is_empty();
let project = self.project.read(cx);
if has_worktree {
@ -2693,7 +2688,7 @@ impl Panel for ProjectPanel {
fn icon(&self, cx: &WindowContext) -> Option<IconName> {
ProjectPanelSettings::get_global(cx)
.button
.then(|| IconName::FileTree)
.then_some(IconName::FileTree)
}
fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {
@ -2796,9 +2791,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/root1".as_ref(), "/root2".as_ref()], cx).await;
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let cx = &mut VisualTestContext::from_window(*workspace, cx);
let panel = workspace
.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx))
.unwrap();
let panel = workspace.update(cx, ProjectPanel::new).unwrap();
assert_eq!(
visible_entries_as_strings(&panel, 0..50, cx),
&[
@ -2895,9 +2888,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/root1".as_ref(), "/root2".as_ref()], cx).await;
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let cx = &mut VisualTestContext::from_window(*workspace, cx);
let panel = workspace
.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx))
.unwrap();
let panel = workspace.update(cx, ProjectPanel::new).unwrap();
assert_eq!(
visible_entries_as_strings(&panel, 0..50, cx),
&[
@ -3011,9 +3002,7 @@ mod tests {
cx,
);
});
let panel = workspace
.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx))
.unwrap();
let panel = workspace.update(cx, ProjectPanel::new).unwrap();
assert_eq!(
visible_entries_as_strings(&panel, 0..10, cx),
&[
@ -3665,9 +3654,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/root1".as_ref()], cx).await;
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let cx = &mut VisualTestContext::from_window(*workspace, cx);
let panel = workspace
.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx))
.unwrap();
let panel = workspace.update(cx, ProjectPanel::new).unwrap();
panel.update(cx, |panel, cx| {
panel.select_next(&Default::default(), cx);
@ -3758,9 +3745,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/root1".as_ref(), "/root2".as_ref()], cx).await;
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let cx = &mut VisualTestContext::from_window(*workspace, cx);
let panel = workspace
.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx))
.unwrap();
let panel = workspace.update(cx, ProjectPanel::new).unwrap();
select_path(&panel, "root1/three.txt", cx);
panel.update(cx, |panel, cx| {
@ -3856,9 +3841,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/root1".as_ref(), "/root2".as_ref()], cx).await;
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let cx = &mut VisualTestContext::from_window(*workspace, cx);
let panel = workspace
.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx))
.unwrap();
let panel = workspace.update(cx, ProjectPanel::new).unwrap();
select_path(&panel, "root1/three.txt", cx);
panel.update(cx, |panel, cx| {
@ -3975,9 +3958,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/root".as_ref()], cx).await;
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let cx = &mut VisualTestContext::from_window(*workspace, cx);
let panel = workspace
.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx))
.unwrap();
let panel = workspace.update(cx, ProjectPanel::new).unwrap();
select_path(&panel, "root/a", cx);
panel.update(cx, |panel, cx| {
@ -4068,9 +4049,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/src".as_ref()], cx).await;
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let cx = &mut VisualTestContext::from_window(*workspace, cx);
let panel = workspace
.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx))
.unwrap();
let panel = workspace.update(cx, ProjectPanel::new).unwrap();
toggle_expand_dir(&panel, "src/test", cx);
select_path(&panel, "src/test/first.rs", cx);
@ -4329,9 +4308,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/project_root".as_ref()], cx).await;
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let cx = &mut VisualTestContext::from_window(*workspace, cx);
let panel = workspace
.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx))
.unwrap();
let panel = workspace.update(cx, ProjectPanel::new).unwrap();
panel.update(cx, |panel, cx| panel.open(&Open, cx));
cx.executor().run_until_parked();
@ -4382,9 +4359,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/project_root".as_ref()], cx).await;
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let cx = &mut VisualTestContext::from_window(*workspace, cx);
let panel = workspace
.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx))
.unwrap();
let panel = workspace.update(cx, ProjectPanel::new).unwrap();
panel.update(cx, |panel, cx| {
panel.collapse_all_entries(&CollapseAllEntries, cx)
@ -4421,9 +4396,7 @@ mod tests {
let project = Project::test(fs, ["/root".as_ref()], cx).await;
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let cx = &mut VisualTestContext::from_window(*workspace, cx);
let panel = workspace
.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx))
.unwrap();
let panel = workspace.update(cx, ProjectPanel::new).unwrap();
// Make a new buffer with no backing file
workspace
@ -4503,9 +4476,7 @@ mod tests {
cx.update(|cx| project.read(cx).worktrees(cx).next().unwrap().read(cx).id());
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let cx = &mut VisualTestContext::from_window(*workspace, cx);
let panel = workspace
.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx))
.unwrap();
let panel = workspace.update(cx, ProjectPanel::new).unwrap();
cx.update(|cx| {
panel.update(cx, |this, cx| {
this.select_next(&Default::default(), cx);
@ -4697,9 +4668,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/project_root".as_ref()], cx).await;
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let cx = &mut VisualTestContext::from_window(*workspace, cx);
let panel = workspace
.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx))
.unwrap();
let panel = workspace.update(cx, ProjectPanel::new).unwrap();
assert_eq!(
visible_entries_as_strings(&panel, 0..20, cx),
@ -4935,9 +4904,7 @@ mod tests {
let project = Project::test(fs.clone(), ["/project_root".as_ref()], cx).await;
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
let cx = &mut VisualTestContext::from_window(*workspace, cx);
let panel = workspace
.update(cx, |workspace, cx| ProjectPanel::new(workspace, cx))
.unwrap();
let panel = workspace.update(cx, ProjectPanel::new).unwrap();
assert_eq!(
visible_entries_as_strings(&panel, 0..20, cx),

View file

@ -1,4 +1,3 @@
use anyhow;
use gpui::Pixels;
use schemars::JsonSchema;
use serde_derive::{Deserialize, Serialize};