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.

Do not show inline blame information on empty lines (#11294)

Thorsten Ball23f191450e8a
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 76f75aae700..86ed6d71b83 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -9114,7 +9114,10 @@ impl Editor {
}
pub fn render_git_blame_inline(&mut self, cx: &mut WindowContext) -> bool {
- self.focus_handle.is_focused(cx) && self.show_git_blame_inline && self.has_blame_entries(cx)
+ self.show_git_blame_inline
+ && self.focus_handle.is_focused(cx)
+ && !self.newest_selection_head_on_empty_line(cx)
+ && self.has_blame_entries(cx)
}
fn has_blame_entries(&self, cx: &mut WindowContext) -> bool {
@@ -9122,6 +9125,15 @@ impl Editor {
.map_or(false, |blame| blame.read(cx).has_generated_entries())
}
+ fn newest_selection_head_on_empty_line(&mut self, cx: &mut WindowContext) -> bool {
+ let cursor_anchor = self.selections.newest_anchor().head();
+
+ let snapshot = self.buffer.read(cx).snapshot(cx);
+ let buffer_row = cursor_anchor.to_point(&snapshot).row;
+
+ snapshot.line_len(buffer_row) == 0
+ }
+
fn get_permalink_to_line(&mut self, cx: &mut ViewContext<Self>) -> Result<url::Url> {
let (path, repo) = maybe!({
let project_handle = self.project.as_ref()?.clone();