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

@ -227,7 +227,7 @@ impl ChannelView {
{
self.editor.update(cx, |editor, cx| {
editor.change_selections(Some(Autoscroll::focused()), cx, |s| {
s.replace_cursors_with(|map| vec![item.range.start.to_display_point(&map)])
s.replace_cursors_with(|map| vec![item.range.start.to_display_point(map)])
})
});
return;
@ -460,8 +460,7 @@ impl Item for ChannelView {
}
fn deactivated(&mut self, cx: &mut ViewContext<Self>) {
self.editor
.update(cx, |editor, cx| Item::deactivated(editor, cx))
self.editor.update(cx, Item::deactivated)
}
fn set_nav_history(&mut self, history: ItemNavHistory, cx: &mut ViewContext<Self>) {

View file

@ -560,7 +560,7 @@ impl ChatPanel {
},
)
.child(
self.render_popover_buttons(&cx, message_id, can_delete_message, can_edit_message)
self.render_popover_buttons(cx, message_id, can_delete_message, can_edit_message)
.mt_neg_2p5(),
)
}
@ -705,7 +705,7 @@ impl ChatPanel {
menu.entry(
"Copy message text",
None,
cx.handler_for(&this, move |this, cx| {
cx.handler_for(this, move |this, cx| {
if let Some(message) = this.active_chat().and_then(|active_chat| {
active_chat.read(cx).find_loaded_message(message_id)
}) {
@ -718,7 +718,7 @@ impl ChatPanel {
menu.entry(
"Delete message",
None,
cx.handler_for(&this, move |this, cx| this.remove_message(message_id, cx)),
cx.handler_for(this, move |this, cx| this.remove_message(message_id, cx)),
)
})
})
@ -802,13 +802,11 @@ impl ChatPanel {
{
task.detach();
}
} else {
if let Some(task) = chat
.update(cx, |chat, cx| chat.send_message(message, cx))
.log_err()
{
task.detach();
}
} else if let Some(task) = chat
.update(cx, |chat, cx| chat.send_message(message, cx))
.log_err()
{
task.detach();
}
}
}
@ -854,7 +852,7 @@ impl ChatPanel {
let scroll_to_message_id = this.update(&mut cx, |this, cx| {
this.set_active_chat(chat.clone(), cx);
scroll_to_message_id.or_else(|| this.last_acknowledged_message_id)
scroll_to_message_id.or(this.last_acknowledged_message_id)
})?;
if let Some(message_id) = scroll_to_message_id {

View file

@ -293,8 +293,8 @@ impl MessageEditor {
completion_fn: impl Fn(&StringMatch) -> (String, CodeLabel),
) -> Vec<Completion> {
let matches = fuzzy::match_strings(
&candidates,
&query,
candidates,
query,
true,
10,
&Default::default(),

View file

@ -219,7 +219,7 @@ impl CollabPanel {
})
.detach();
let channel_name_editor = cx.new_view(|cx| Editor::single_line(cx));
let channel_name_editor = cx.new_view(Editor::single_line);
cx.subscribe(&channel_name_editor, |this: &mut Self, _, event, cx| {
if let editor::EditorEvent::Blurred = event {
@ -328,7 +328,7 @@ impl CollabPanel {
panel.width = serialized_panel.width.map(|w| w.round());
panel.collapsed_channels = serialized_panel
.collapsed_channels
.unwrap_or_else(|| Vec::new())
.unwrap_or_else(Vec::new)
.iter()
.map(|cid| ChannelId(*cid))
.collect();
@ -955,7 +955,7 @@ impl CollabPanel {
}
fn take_editing_state(&mut self, cx: &mut ViewContext<Self>) -> bool {
if let Some(_) = self.channel_editing_state.take() {
if self.channel_editing_state.take().is_some() {
self.channel_name_editor.update(cx, |editor, cx| {
editor.set_text("", cx);
});
@ -1850,8 +1850,7 @@ impl CollabPanel {
if let Some(contact) = self.selected_contact() {
self.deploy_contact_context_menu(bounds.center(), contact, cx);
cx.stop_propagation();
return;
};
}
}
fn selected_channel(&self) -> Option<&Arc<Channel>> {
@ -2142,7 +2141,7 @@ impl CollabPanel {
} => self
.render_participant_project(
*project_id,
&worktree_root_names,
worktree_root_names,
*host_user_id,
*is_last,
is_selected,
@ -2401,7 +2400,7 @@ impl CollabPanel {
) -> impl IntoElement {
let github_login = SharedString::from(user.github_login.clone());
let user_id = user.id;
let is_response_pending = self.user_store.read(cx).is_contact_request_pending(&user);
let is_response_pending = self.user_store.read(cx).is_contact_request_pending(user);
let color = if is_response_pending {
Color::Muted
} else {
@ -2457,7 +2456,7 @@ impl CollabPanel {
let response_is_pending = self
.channel_store
.read(cx)
.has_pending_channel_invite_response(&channel);
.has_pending_channel_invite_response(channel);
let color = if response_is_pending {
Color::Muted
} else {
@ -2832,7 +2831,7 @@ impl Panel for CollabPanel {
fn icon(&self, cx: &gpui::WindowContext) -> Option<ui::IconName> {
CollaborationPanelSettings::get_global(cx)
.button
.then(|| ui::IconName::Collab)
.then_some(ui::IconName::Collab)
}
fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {

View file

@ -309,7 +309,7 @@ impl PickerDelegate for ChannelModalDelegate {
let members = search_members.await?;
picker.update(&mut cx, |picker, cx| {
picker.delegate.has_all_members =
query == "" && members.len() < 100;
query.is_empty() && members.len() < 100;
picker.delegate.matching_member_indices =
(0..members.len()).collect();
picker.delegate.members = members;

View file

@ -154,7 +154,7 @@ impl PickerDelegate for ContactFinderDelegate {
.selected(selected)
.start_slot(Avatar::new(user.avatar_uri.clone()))
.child(Label::new(user.github_login.clone()))
.end_slot::<Icon>(icon_path.map(|icon_path| Icon::from_path(icon_path))),
.end_slot::<Icon>(icon_path.map(Icon::from_path)),
)
}
}

View file

@ -31,7 +31,7 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
chat_panel::init(cx);
collab_panel::init(cx);
notification_panel::init(cx);
notifications::init(&app_state, cx);
notifications::init(app_state, cx);
title_bar::init(cx);
vcs_menu::init(cx);
}

View file

@ -92,7 +92,7 @@ impl NotificationPanel {
cx.new_view(|cx: &mut ViewContext<Self>| {
let mut status = client.status();
cx.spawn(|this, mut cx| async move {
while let Some(_) = status.next().await {
while (status.next().await).is_some() {
if this
.update(&mut cx, |_, cx| {
cx.notify();

View file

@ -52,7 +52,7 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
room::Event::RemoteProjectUnshared { project_id }
| room::Event::RemoteProjectJoined { project_id }
| room::Event::RemoteProjectInvitationDiscarded { project_id } => {
if let Some(windows) = notification_windows.remove(&project_id) {
if let Some(windows) = notification_windows.remove(project_id) {
for window in windows {
window
.update(cx, |_, cx| {

View file

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