Fix formatting in various files (#42917)
This fixes various issues where rustfmt failed to format code due to too long strings, most of which I stumbled across over the last week and some additonal ones I searched for whilst fixing the others. Release Notes: - N/A
This commit is contained in:
+55
-41
@@ -1918,53 +1918,67 @@ fn open_telemetry_log_file(
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Workspace>,
|
||||
) {
|
||||
workspace.with_local_workspace(window, cx, move |workspace, window, cx| {
|
||||
let app_state = workspace.app_state().clone();
|
||||
cx.spawn_in(window, async move |workspace, cx| {
|
||||
async fn fetch_log_string(app_state: &Arc<AppState>) -> Option<String> {
|
||||
let path = client::telemetry::Telemetry::log_file_path();
|
||||
app_state.fs.load(&path).await.log_err()
|
||||
}
|
||||
const HEADER: &str = concat!(
|
||||
"// Zed collects anonymous usage data to help us understand how people are using the app.\n",
|
||||
"// Telemetry can be disabled via the `settings.json` file.\n",
|
||||
"// Here is the data that has been reported for the current session:\n",
|
||||
);
|
||||
workspace
|
||||
.with_local_workspace(window, cx, move |workspace, window, cx| {
|
||||
let app_state = workspace.app_state().clone();
|
||||
cx.spawn_in(window, async move |workspace, cx| {
|
||||
async fn fetch_log_string(app_state: &Arc<AppState>) -> Option<String> {
|
||||
let path = client::telemetry::Telemetry::log_file_path();
|
||||
app_state.fs.load(&path).await.log_err()
|
||||
}
|
||||
|
||||
let log = fetch_log_string(&app_state).await.unwrap_or_else(|| "// No data has been collected yet".to_string());
|
||||
let log = fetch_log_string(&app_state)
|
||||
.await
|
||||
.unwrap_or_else(|| "// No data has been collected yet".to_string());
|
||||
|
||||
const MAX_TELEMETRY_LOG_LEN: usize = 5 * 1024 * 1024;
|
||||
let mut start_offset = log.len().saturating_sub(MAX_TELEMETRY_LOG_LEN);
|
||||
if let Some(newline_offset) = log[start_offset..].find('\n') {
|
||||
start_offset += newline_offset + 1;
|
||||
}
|
||||
let log_suffix = &log[start_offset..];
|
||||
let header = concat!(
|
||||
"// Zed collects anonymous usage data to help us understand how people are using the app.\n",
|
||||
"// Telemetry can be disabled via the `settings.json` file.\n",
|
||||
"// Here is the data that has been reported for the current session:\n",
|
||||
);
|
||||
let content = format!("{}\n{}", header, log_suffix);
|
||||
let json = app_state.languages.language_for_name("JSON").await.log_err();
|
||||
const MAX_TELEMETRY_LOG_LEN: usize = 5 * 1024 * 1024;
|
||||
let mut start_offset = log.len().saturating_sub(MAX_TELEMETRY_LOG_LEN);
|
||||
if let Some(newline_offset) = log[start_offset..].find('\n') {
|
||||
start_offset += newline_offset + 1;
|
||||
}
|
||||
let log_suffix = &log[start_offset..];
|
||||
let content = format!("{}\n{}", HEADER, log_suffix);
|
||||
let json = app_state
|
||||
.languages
|
||||
.language_for_name("JSON")
|
||||
.await
|
||||
.log_err();
|
||||
|
||||
workspace.update_in( cx, |workspace, window, cx| {
|
||||
let project = workspace.project().clone();
|
||||
let buffer = project.update(cx, |project, cx| project.create_local_buffer(&content, json,false, cx));
|
||||
let buffer = cx.new(|cx| {
|
||||
MultiBuffer::singleton(buffer, cx).with_title("Telemetry Log".into())
|
||||
});
|
||||
workspace.add_item_to_active_pane(
|
||||
Box::new(cx.new(|cx| {
|
||||
let mut editor = Editor::for_multibuffer(buffer, Some(project), window, cx);
|
||||
editor.set_read_only(true);
|
||||
editor.set_breadcrumb_header("Telemetry Log".into());
|
||||
editor
|
||||
})),
|
||||
None,
|
||||
true,
|
||||
window, cx,
|
||||
);
|
||||
}).log_err()?;
|
||||
workspace
|
||||
.update_in(cx, |workspace, window, cx| {
|
||||
let project = workspace.project().clone();
|
||||
let buffer = project.update(cx, |project, cx| {
|
||||
project.create_local_buffer(&content, json, false, cx)
|
||||
});
|
||||
let buffer = cx.new(|cx| {
|
||||
MultiBuffer::singleton(buffer, cx).with_title("Telemetry Log".into())
|
||||
});
|
||||
workspace.add_item_to_active_pane(
|
||||
Box::new(cx.new(|cx| {
|
||||
let mut editor =
|
||||
Editor::for_multibuffer(buffer, Some(project), window, cx);
|
||||
editor.set_read_only(true);
|
||||
editor.set_breadcrumb_header("Telemetry Log".into());
|
||||
editor
|
||||
})),
|
||||
None,
|
||||
true,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
})
|
||||
.log_err()?;
|
||||
|
||||
Some(())
|
||||
Some(())
|
||||
})
|
||||
.detach();
|
||||
})
|
||||
.detach();
|
||||
}).detach();
|
||||
}
|
||||
|
||||
fn open_bundled_file(
|
||||
|
||||
Reference in New Issue
Block a user