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.

Don't allow open excerpts in commit view for now (#27862)

Max Brunsfeldb59967bbdfe6
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 24432c21314..4ba1fce1282 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -17212,6 +17212,9 @@ impl Editor {
}
}
+ new_selections_by_buffer
+ .retain(|buffer, _| Self::can_open_excerpts_in_file(buffer.read(cx).file()));
+
if new_selections_by_buffer.is_empty() {
return;
}
@@ -17280,6 +17283,12 @@ impl Editor {
});
}
+ // For now, don't allow opening excerpts in buffers that aren't backed by
+ // regular project files.
+ fn can_open_excerpts_in_file(file: Option<&Arc<dyn language::File>>) -> bool {
+ file.map_or(true, |file| project::File::from_dyn(Some(file)).is_some())
+ }
+
fn marked_text_ranges(&self, cx: &App) -> Option<Vec<Range<OffsetUtf16>>> {
let snapshot = self.buffer.read(cx).read(cx);
let (_, ranges) = self.text_highlights::<InputComposition>(cx)?;
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs
index 1c6fe39d18d..5745ee146ad 100644
--- a/crates/editor/src/element.rs
+++ b/crates/editor/src/element.rs
@@ -2791,6 +2791,7 @@ impl EditorElement {
.as_ref()
.map(|project| project.read(cx).visible_worktrees(cx).count() > 1)
.unwrap_or_default();
+ let can_open_excerpts = Editor::can_open_excerpts_in_file(for_excerpt.buffer.file());
let path = for_excerpt.buffer.resolve_file_path(cx, include_root);
let filename = path
.as_ref()
@@ -2920,7 +2921,7 @@ impl EditorElement {
))
}),
)
- .when(is_selected, |el| {
+ .when(can_open_excerpts && is_selected && path.is_some(), |el| {
el.child(
h_flex()
.id("jump-to-file-button")