Fix overlapping block headers when using custom line height (#4071)

This fixes block headers overlapping over text in the buffer when using
a custom line height of 1.25.

It fixes the issue by making the parent container a v-flex,
vertically-justifying the content and moving from relative padding to
absolute padding for the header itself.

## Before/After

With setting:
```json
  "buffer_line_height": {
    "custom": 1.25
  },
```

### Before

![screenshot-2024-01-16-16 48
48@2x](https://github.com/zed-industries/zed/assets/1185253/8c3b977e-333f-403c-a4d3-0911f3fac5e0)

### After

![screenshot-2024-01-16-16 50
13@2x](https://github.com/zed-industries/zed/assets/1185253/2d854eba-c4c4-4bce-b60b-dd250856b08f)

### Release notes
Release Notes:

- Fixed headers in multi-buffers overlapping over content of the buffer
This commit is contained in:
Thorsten Ball 2024-01-16 17:27:36 +01:00 committed by GitHub
commit 3d041f4e91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 39 deletions

View file

@ -2288,17 +2288,18 @@ impl EditorElement {
.map(|p| SharedString::from(p.to_string_lossy().to_string() + "/")); .map(|p| SharedString::from(p.to_string_lossy().to_string() + "/"));
} }
div() v_flex()
.id(("path header container", block_id)) .id(("path header container", block_id))
.size_full() .size_full()
.p_1p5() .justify_center()
.p(gpui::px(6.))
.child( .child(
h_flex() h_flex()
.id("path header block") .id("path header block")
.py_1p5() .size_full()
.pl_3() .pl(gpui::px(12.))
.pr_2() .pr(gpui::px(8.))
.rounded_lg() .rounded_md()
.shadow_md() .shadow_md()
.border() .border()
.border_color(cx.theme().colors().border) .border_color(cx.theme().colors().border)
@ -2861,6 +2862,7 @@ impl Element for EditorElement {
cx.with_text_style( cx.with_text_style(
Some(gpui::TextStyleRefinement { Some(gpui::TextStyleRefinement {
font_size: Some(self.style.text.font_size), font_size: Some(self.style.text.font_size),
line_height: Some(self.style.text.line_height),
..Default::default() ..Default::default()
}), }),
|cx| { |cx| {

View file

@ -282,6 +282,8 @@ impl EventEmitter<ViewEvent> for ProjectSearchView {}
impl Render for ProjectSearchView { impl Render for ProjectSearchView {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
const PLEASE_AUTHENTICATE: &str = "API Key Missing: Please set 'OPENAI_API_KEY' in Environment Variables. If you authenticated using the Assistant Panel, please restart Zed to Authenticate.";
if self.has_matches() { if self.has_matches() {
div() div()
.flex_1() .flex_1()
@ -307,8 +309,7 @@ impl Render for ProjectSearchView {
SemanticIndexStatus::NotAuthenticated => { SemanticIndexStatus::NotAuthenticated => {
major_text = Label::new("Not Authenticated"); major_text = Label::new("Not Authenticated");
show_minor_text = false; show_minor_text = false;
Some( Some(PLEASE_AUTHENTICATE.to_string())
"API Key Missing: Please set 'OPENAI_API_KEY' in Environment Variables. If you authenticated using the Assistant Panel, please restart Zed to Authenticate.".to_string())
} }
SemanticIndexStatus::Indexed => Some("Indexing complete".to_string()), SemanticIndexStatus::Indexed => Some("Indexing complete".to_string()),
SemanticIndexStatus::Indexing { SemanticIndexStatus::Indexing {