Ignore custom buffer line height for context menus (#25172)
Closes #24504 Release Notes: - Fixed a visual bug that could make context menus unusable when setting a custom `buffer_line_height`.
This commit is contained in:
parent
6a9b1f0dc4
commit
1ce8a51712
1 changed files with 112 additions and 95 deletions
|
@ -68,7 +68,7 @@ use std::{
|
|||
};
|
||||
use sum_tree::Bias;
|
||||
use text::BufferId;
|
||||
use theme::{ActiveTheme, Appearance, PlayerColor};
|
||||
use theme::{ActiveTheme, Appearance, BufferLineHeight, PlayerColor};
|
||||
use ui::{
|
||||
h_flex, prelude::*, ButtonLike, ButtonStyle, ContextMenu, IconButtonShape, KeyBinding, Tooltip,
|
||||
POPOVER_Y_PADDING,
|
||||
|
@ -3334,6 +3334,13 @@ impl EditorElement {
|
|||
&mut App,
|
||||
) -> Vec<(CursorPopoverType, AnyElement, Size<Pixels>)>,
|
||||
) -> Option<(Vec<(CursorPopoverType, Bounds<Pixels>)>, bool)> {
|
||||
let text_style = TextStyleRefinement {
|
||||
line_height: Some(DefiniteLength::Fraction(
|
||||
BufferLineHeight::Comfortable.value(),
|
||||
)),
|
||||
..Default::default()
|
||||
};
|
||||
window.with_text_style(Some(text_style), |window| {
|
||||
// If the max height won't fit below and there is more space above, put it above the line.
|
||||
let bottom_y_when_flipped = target_position.y - line_height;
|
||||
let available_above = bottom_y_when_flipped - text_hitbox.top();
|
||||
|
@ -3372,7 +3379,8 @@ impl EditorElement {
|
|||
|
||||
// TODO: Use viewport_bounds.width as a max width so that it doesn't get clipped on the left
|
||||
// for very narrow windows.
|
||||
let popovers = make_sized_popovers(height, max_width_for_stable_x, y_flipped, window, cx);
|
||||
let popovers =
|
||||
make_sized_popovers(height, max_width_for_stable_x, y_flipped, window, cx);
|
||||
if popovers.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
@ -3418,6 +3426,7 @@ impl EditorElement {
|
|||
}
|
||||
|
||||
Some((laid_out_popovers, y_flipped))
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
|
@ -3978,6 +3987,13 @@ impl EditorElement {
|
|||
}
|
||||
})?;
|
||||
|
||||
let text_style = TextStyleRefinement {
|
||||
line_height: Some(DefiniteLength::Fraction(
|
||||
BufferLineHeight::Comfortable.value(),
|
||||
)),
|
||||
..Default::default()
|
||||
};
|
||||
window.with_text_style(Some(text_style), |window| {
|
||||
let mut element = self.editor.update(cx, |editor, _| {
|
||||
let mouse_context_menu = editor.mouse_context_menu.as_ref()?;
|
||||
let context_menu = mouse_context_menu.context_menu.clone();
|
||||
|
@ -3997,6 +4013,7 @@ impl EditorElement {
|
|||
|
||||
element.prepaint_as_root(position, AvailableSpace::min_size(), window, cx);
|
||||
Some(element)
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue