Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Show location of log file when using `zed: open log` (#13252)

Thorsten Ball8c4fb34f6e54
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 0696e4b5acd..5e1c6ee8cca 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -552,6 +552,7 @@ pub struct Editor {
tasks_update_task: Option<Task<()>>,
previous_search_ranges: Option<Arc<[Range<Anchor>]>>,
file_header_size: u8,
+ breadcrumb_header: Option<String>,
}
#[derive(Clone)]
@@ -1863,6 +1864,7 @@ impl Editor {
tasks_update_task: None,
linked_edit_ranges: Default::default(),
previous_search_ranges: None,
+ breadcrumb_header: None,
};
this.tasks_update_task = Some(this.refresh_runnables(cx));
this._subscriptions.extend(project_subscriptions);
@@ -10505,6 +10507,10 @@ impl Editor {
)
}
+ pub fn set_breadcrumb_header(&mut self, new_header: String) {
+ self.breadcrumb_header = Some(new_header);
+ }
+
pub fn clear_search_within_ranges(&mut self, cx: &mut ViewContext<Self>) {
self.clear_background_highlights::<SearchWithinRange>(cx);
}
diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs
index b112e779079..2dc0b6c6164 100644
--- a/crates/editor/src/items.rs
+++ b/crates/editor/src/items.rs
@@ -816,22 +816,24 @@ impl Item for Editor {
let buffer = multibuffer.buffer(buffer_id)?;
let buffer = buffer.read(cx);
- let filename = buffer
- .snapshot()
- .resolve_file_path(
- cx,
- self.project
- .as_ref()
- .map(|project| project.read(cx).visible_worktrees(cx).count() > 1)
- .unwrap_or_default(),
- )
- .map(|path| path.to_string_lossy().to_string())
- .unwrap_or_else(|| "untitled".to_string());
+ let text = self.breadcrumb_header.clone().unwrap_or_else(|| {
+ buffer
+ .snapshot()
+ .resolve_file_path(
+ cx,
+ self.project
+ .as_ref()
+ .map(|project| project.read(cx).visible_worktrees(cx).count() > 1)
+ .unwrap_or_default(),
+ )
+ .map(|path| path.to_string_lossy().to_string())
+ .unwrap_or_else(|| "untitled".to_string())
+ });
let settings = ThemeSettings::get_global(cx);
let mut breadcrumbs = vec![BreadcrumbText {
- text: filename,
+ text,
highlights: None,
font: Some(settings.buffer_font.clone()),
}];
diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs
index 9407c39bade..bf48d30be14 100644
--- a/crates/zed/src/zed.rs
+++ b/crates/zed/src/zed.rs
@@ -633,7 +633,14 @@ fn open_log_file(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) {
MultiBuffer::singleton(buffer, cx).with_title("Log".into())
});
let editor = cx.new_view(|cx| {
- Editor::for_multibuffer(buffer, Some(project), true, cx)
+ let mut editor =
+ Editor::for_multibuffer(buffer, Some(project), true, cx);
+ editor.set_breadcrumb_header(format!(
+ "Last {} lines in {}",
+ MAX_LINES,
+ paths::log_file().display()
+ ));
+ editor
});
editor.update(cx, |editor, cx| {