Improve buffers used by Zed for discoverability/visibility (#16906)
- Fixed Telemetry log being marked dirty. - Fixed asset buffers (default settings and default keymap) showing 'untitled' in breadcrumbs
This commit is contained in:
parent
93a7682659
commit
c2835df898
1 changed files with 17 additions and 22 deletions
|
@ -916,35 +916,26 @@ fn open_telemetry_log_file(workspace: &mut Workspace, cx: &mut ViewContext<Works
|
||||||
start_offset += newline_offset + 1;
|
start_offset += newline_offset + 1;
|
||||||
}
|
}
|
||||||
let log_suffix = &log[start_offset..];
|
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();
|
let json = app_state.languages.language_for_name("JSON").await.log_err();
|
||||||
|
|
||||||
workspace.update(&mut cx, |workspace, cx| {
|
workspace.update(&mut cx, |workspace, cx| {
|
||||||
let project = workspace.project().clone();
|
let project = workspace.project().clone();
|
||||||
let buffer = project
|
let buffer = project.update(cx, |project, cx| project.create_local_buffer(&content, json, cx));
|
||||||
.update(cx, |project, cx| project.create_local_buffer("", None, cx));
|
|
||||||
buffer.update(cx, |buffer, cx| {
|
|
||||||
buffer.set_language(json, cx);
|
|
||||||
buffer.edit(
|
|
||||||
[(
|
|
||||||
0..0,
|
|
||||||
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",
|
|
||||||
"\n"
|
|
||||||
),
|
|
||||||
)],
|
|
||||||
None,
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
buffer.edit([(buffer.len()..buffer.len(), log_suffix)], None, cx);
|
|
||||||
});
|
|
||||||
|
|
||||||
let buffer = cx.new_model(|cx| {
|
let buffer = cx.new_model(|cx| {
|
||||||
MultiBuffer::singleton(buffer, cx).with_title("Telemetry Log".into())
|
MultiBuffer::singleton(buffer, cx).with_title("Telemetry Log".into())
|
||||||
});
|
});
|
||||||
workspace.add_item_to_active_pane(
|
workspace.add_item_to_active_pane(
|
||||||
Box::new(cx.new_view(|cx| Editor::for_multibuffer(buffer, Some(project), true, cx))),
|
Box::new(cx.new_view(|cx| {
|
||||||
|
let mut editor = Editor::for_multibuffer(buffer, Some(project), true, cx);
|
||||||
|
editor.set_breadcrumb_header("Telemetry Log".into());
|
||||||
|
editor
|
||||||
|
})),
|
||||||
None,
|
None,
|
||||||
true,
|
true,
|
||||||
cx,
|
cx,
|
||||||
|
@ -979,7 +970,11 @@ fn open_bundled_file(
|
||||||
});
|
});
|
||||||
workspace.add_item_to_active_pane(
|
workspace.add_item_to_active_pane(
|
||||||
Box::new(cx.new_view(|cx| {
|
Box::new(cx.new_view(|cx| {
|
||||||
Editor::for_multibuffer(buffer, Some(project.clone()), true, cx)
|
let mut editor =
|
||||||
|
Editor::for_multibuffer(buffer, Some(project.clone()), true, cx);
|
||||||
|
editor.set_read_only(true);
|
||||||
|
editor.set_breadcrumb_header(title.into());
|
||||||
|
editor
|
||||||
})),
|
})),
|
||||||
None,
|
None,
|
||||||
true,
|
true,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue