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

cc @iamnbutler 

Release Notes:

- Changed inline git blame information to not show up on empty lines.

Demo/proof:



https://github.com/zed-industries/zed/assets/1185253/e506cf1f-81b1-407b-8dc7-1666b31ae142
This commit is contained in:
Thorsten Ball 2024-05-02 12:22:51 +02:00 committed by GitHub
parent edff78e722
commit 23f191450e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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();