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:
parent
93249fc82b
commit
e6c1c51b37
361 changed files with 3530 additions and 3587 deletions
|
@ -23,7 +23,6 @@ use gpui::{
|
|||
Action, App, AppContext, AsyncAppContext, Context, DismissEvent, Global, Task,
|
||||
UpdateGlobal as _, VisualContext,
|
||||
};
|
||||
use image_viewer;
|
||||
use language::LanguageRegistry;
|
||||
use log::LevelFilter;
|
||||
|
||||
|
@ -728,12 +727,12 @@ fn handle_open_request(
|
|||
async fn authenticate(client: Arc<Client>, cx: &AsyncAppContext) -> Result<()> {
|
||||
if stdout_is_a_pty() {
|
||||
if *client::ZED_DEVELOPMENT_AUTH {
|
||||
client.authenticate_and_connect(true, &cx).await?;
|
||||
client.authenticate_and_connect(true, cx).await?;
|
||||
} else if client::IMPERSONATE_LOGIN.is_some() {
|
||||
client.authenticate_and_connect(false, &cx).await?;
|
||||
client.authenticate_and_connect(false, cx).await?;
|
||||
}
|
||||
} else if client.has_credentials(&cx).await {
|
||||
client.authenticate_and_connect(true, &cx).await?;
|
||||
} else if client.has_credentials(cx).await {
|
||||
client.authenticate_and_connect(true, cx).await?;
|
||||
}
|
||||
Ok::<_, anyhow::Error>(())
|
||||
}
|
||||
|
@ -1082,7 +1081,7 @@ fn parse_url_arg(arg: &str, cx: &AppContext) -> Result<String> {
|
|||
|| arg.starts_with("ssh://")
|
||||
{
|
||||
Ok(arg.into())
|
||||
} else if let Some(_) = parse_zed_link(&arg, cx) {
|
||||
} else if parse_zed_link(arg, cx).is_some() {
|
||||
Ok(arg.into())
|
||||
} else {
|
||||
Err(anyhow!("error parsing path argument: {}", error))
|
||||
|
@ -1141,7 +1140,7 @@ fn load_user_themes_in_background(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {
|
|||
}
|
||||
}
|
||||
theme_registry.load_user_themes(themes_dir, fs).await?;
|
||||
cx.update(|cx| ThemeSettings::reload_current_theme(cx))?;
|
||||
cx.update(ThemeSettings::reload_current_theme)?;
|
||||
}
|
||||
anyhow::Ok(())
|
||||
}
|
||||
|
@ -1168,8 +1167,7 @@ fn watch_themes(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {
|
|||
.await
|
||||
.log_err()
|
||||
{
|
||||
cx.update(|cx| ThemeSettings::reload_current_theme(cx))
|
||||
.log_err();
|
||||
cx.update(ThemeSettings::reload_current_theme).log_err();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ pub fn init_panic_hook(
|
|||
.payload()
|
||||
.downcast_ref::<&str>()
|
||||
.map(|s| s.to_string())
|
||||
.or_else(|| info.payload().downcast_ref::<String>().map(|s| s.clone()))
|
||||
.or_else(|| info.payload().downcast_ref::<String>().cloned())
|
||||
.unwrap_or_else(|| "Box<Any>".to_string());
|
||||
|
||||
if *release_channel::RELEASE_CHANNEL == ReleaseChannel::Dev {
|
||||
|
@ -226,7 +226,7 @@ pub fn monitor_main_thread_hangs(
|
|||
|
||||
let (mut tx, mut rx) = futures::channel::mpsc::channel(3);
|
||||
foreground_executor
|
||||
.spawn(async move { while let Some(_) = rx.next().await {} })
|
||||
.spawn(async move { while (rx.next().await).is_some() {} })
|
||||
.detach();
|
||||
|
||||
background_executor
|
||||
|
@ -259,7 +259,7 @@ pub fn monitor_main_thread_hangs(
|
|||
let os_version = client::telemetry::os_version();
|
||||
|
||||
loop {
|
||||
while let Some(_) = backtrace_rx.recv().ok() {
|
||||
while backtrace_rx.recv().is_ok() {
|
||||
if !telemetry_settings.diagnostics {
|
||||
return;
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ async fn upload_previous_panics(
|
|||
Ok::<_, anyhow::Error>(most_recent_panic)
|
||||
}
|
||||
|
||||
static LAST_CRASH_UPLOADED: &'static str = "LAST_CRASH_UPLOADED";
|
||||
static LAST_CRASH_UPLOADED: &str = "LAST_CRASH_UPLOADED";
|
||||
|
||||
/// upload crashes from apple's diagnostic reports to our server.
|
||||
/// (only if telemetry is enabled)
|
||||
|
|
|
@ -203,7 +203,7 @@ pub fn initialize_workspace(
|
|||
activity_indicator::ActivityIndicator::new(workspace, app_state.languages.clone(), cx);
|
||||
let active_buffer_language =
|
||||
cx.new_view(|_| language_selector::ActiveBufferLanguage::new(workspace));
|
||||
let vim_mode_indicator = cx.new_view(|cx| vim::ModeIndicator::new(cx));
|
||||
let vim_mode_indicator = cx.new_view(vim::ModeIndicator::new);
|
||||
let cursor_position =
|
||||
cx.new_view(|_| go_to_line::cursor_position::CursorPosition::new(workspace));
|
||||
workspace.status_bar().update(cx, |status_bar, cx| {
|
||||
|
@ -236,7 +236,7 @@ pub fn initialize_workspace(
|
|||
let fs = app_state.fs.clone();
|
||||
project.task_inventory().update(cx, |inventory, cx| {
|
||||
let tasks_file_rx =
|
||||
watch_config_file(&cx.background_executor(), fs, paths::tasks_file().clone());
|
||||
watch_config_file(cx.background_executor(), fs, paths::tasks_file().clone());
|
||||
inventory.add_source(
|
||||
TaskSourceKind::AbsPath {
|
||||
id_base: "global_tasks".into(),
|
||||
|
@ -423,7 +423,7 @@ pub fn initialize_workspace(
|
|||
move |_: &mut Workspace,
|
||||
_: &zed_actions::OpenKeymap,
|
||||
cx: &mut ViewContext<Workspace>| {
|
||||
open_settings_file(&paths::keymap_file(), || settings::initial_keymap_content().as_ref().into(), cx);
|
||||
open_settings_file(paths::keymap_file(), || settings::initial_keymap_content().as_ref().into(), cx);
|
||||
},
|
||||
)
|
||||
.register_action(
|
||||
|
@ -628,8 +628,8 @@ fn quit(_: &Quit, cx: &mut AppContext) {
|
|||
|
||||
// If multiple windows have unsaved changes, and need a save prompt,
|
||||
// prompt in the active window before switching to a different window.
|
||||
cx.update(|mut cx| {
|
||||
workspace_windows.sort_by_key(|window| window.is_active(&mut cx) == Some(false));
|
||||
cx.update(|cx| {
|
||||
workspace_windows.sort_by_key(|window| window.is_active(cx) == Some(false));
|
||||
})
|
||||
.log_err();
|
||||
|
||||
|
@ -1029,7 +1029,7 @@ fn open_settings_file(
|
|||
// TODO: Do note that all other external files (e.g. drag and drop from OS) still have their worktrees released on file close, causing LSP servers' restarts.
|
||||
project.find_or_create_worktree(paths::config_dir().as_path(), false, cx)
|
||||
});
|
||||
let settings_open_task = create_and_open_local_file(&abs_path, cx, default_content);
|
||||
let settings_open_task = create_and_open_local_file(abs_path, cx, default_content);
|
||||
(worktree_creation_task, settings_open_task)
|
||||
})?;
|
||||
|
||||
|
@ -1040,6 +1040,11 @@ fn open_settings_file(
|
|||
.detach_and_log_err(cx);
|
||||
}
|
||||
|
||||
async fn register_zed_scheme(cx: &AsyncAppContext) -> anyhow::Result<()> {
|
||||
cx.update(|cx| cx.register_url_scheme(ZED_URL_SCHEME))?
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
@ -3368,7 +3373,7 @@ mod tests {
|
|||
#[gpui::test]
|
||||
async fn test_bundled_languages(cx: &mut TestAppContext) {
|
||||
env_logger::builder().is_test(true).try_init().ok();
|
||||
let settings = cx.update(|cx| SettingsStore::test(cx));
|
||||
let settings = cx.update(SettingsStore::test);
|
||||
cx.set_global(settings);
|
||||
let languages = LanguageRegistry::test(cx.executor());
|
||||
let languages = Arc::new(languages);
|
||||
|
@ -3387,7 +3392,7 @@ mod tests {
|
|||
}
|
||||
|
||||
pub(crate) fn init_test(cx: &mut TestAppContext) -> Arc<AppState> {
|
||||
init_test_with_state(cx, cx.update(|cx| AppState::test(cx)))
|
||||
init_test_with_state(cx, cx.update(AppState::test))
|
||||
}
|
||||
|
||||
fn init_test_with_state(
|
||||
|
@ -3506,8 +3511,3 @@ mod tests {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn register_zed_scheme(cx: &AsyncAppContext) -> anyhow::Result<()> {
|
||||
cx.update(|cx| cx.register_url_scheme(ZED_URL_SCHEME))?
|
||||
.await
|
||||
}
|
||||
|
|
|
@ -352,14 +352,14 @@ async fn open_workspaces(
|
|||
wait: bool,
|
||||
app_state: Arc<AppState>,
|
||||
env: Option<collections::HashMap<String, String>>,
|
||||
mut cx: &mut AsyncAppContext,
|
||||
cx: &mut AsyncAppContext,
|
||||
) -> Result<()> {
|
||||
let grouped_paths = if paths.is_empty() {
|
||||
// If no paths are provided, restore from previous workspaces unless a new workspace is requested with -n
|
||||
if open_new_workspace == Some(true) {
|
||||
Vec::new()
|
||||
} else {
|
||||
let locations = restorable_workspace_locations(&mut cx, &app_state).await;
|
||||
let locations = restorable_workspace_locations(cx, &app_state).await;
|
||||
locations
|
||||
.into_iter()
|
||||
.flat_map(|locations| {
|
||||
|
@ -423,7 +423,7 @@ async fn open_workspaces(
|
|||
responses,
|
||||
env.as_ref(),
|
||||
&app_state,
|
||||
&mut cx,
|
||||
cx,
|
||||
)
|
||||
.await;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue