mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-05 10:20:51 +00:00
Ensure editors context menus get at least 3 lines of height
This commit is contained in:
parent
139986d080
commit
4fb3e6d812
3 changed files with 15 additions and 9 deletions
|
@ -240,8 +240,8 @@ impl MessageEditor {
|
||||||
text: format!("@{}", mat.string),
|
text: format!("@{}", mat.string),
|
||||||
runs: Vec::new(),
|
runs: Vec::new(),
|
||||||
},
|
},
|
||||||
server_id: LanguageServerId(0), // TODO: Make this optional or something?
|
|
||||||
documentation: None,
|
documentation: None,
|
||||||
|
server_id: LanguageServerId(0), // TODO: Make this optional or something?
|
||||||
lsp_completion: Default::default(), // TODO: Make this optional or something?
|
lsp_completion: Default::default(), // TODO: Make this optional or something?
|
||||||
})
|
})
|
||||||
.collect())
|
.collect())
|
||||||
|
@ -326,7 +326,6 @@ impl Render for MessageEditor {
|
||||||
|
|
||||||
div()
|
div()
|
||||||
.w_full()
|
.w_full()
|
||||||
.h(px(500.))
|
|
||||||
.px_2()
|
.px_2()
|
||||||
.py_1()
|
.py_1()
|
||||||
.bg(cx.theme().colors().editor_background)
|
.bg(cx.theme().colors().editor_background)
|
||||||
|
@ -360,7 +359,7 @@ mod tests {
|
||||||
MessageEditor::new(
|
MessageEditor::new(
|
||||||
language_registry,
|
language_registry,
|
||||||
ChannelStore::global(cx),
|
ChannelStore::global(cx),
|
||||||
cx.new_view(|cx| Editor::auto_height(25, cx)),
|
cx.new_view(|cx| Editor::auto_height(4, cx)),
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
|
@ -1177,9 +1177,9 @@ impl EditorElement {
|
||||||
list_origin.x = (cx.viewport_size().width - list_width).max(Pixels::ZERO);
|
list_origin.x = (cx.viewport_size().width - list_width).max(Pixels::ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if list_origin.y + list_height > text_bounds.lower_right().y {
|
if list_origin.y + list_height > text_bounds.lower_right().y {
|
||||||
// list_origin.y -= layout.position_map.line_height + list_height;
|
list_origin.y -= layout.position_map.line_height + list_height;
|
||||||
// }
|
}
|
||||||
|
|
||||||
cx.break_content_mask(|cx| context_menu.draw(list_origin, available_space, cx));
|
cx.break_content_mask(|cx| context_menu.draw(list_origin, available_space, cx));
|
||||||
}
|
}
|
||||||
|
@ -2128,7 +2128,13 @@ impl EditorElement {
|
||||||
if let Some(newest_selection_head) = newest_selection_head {
|
if let Some(newest_selection_head) = newest_selection_head {
|
||||||
if (start_row..end_row).contains(&newest_selection_head.row()) {
|
if (start_row..end_row).contains(&newest_selection_head.row()) {
|
||||||
if editor.context_menu_visible() {
|
if editor.context_menu_visible() {
|
||||||
let max_height = (12. * line_height).min((bounds.size.height - line_height) / 2.);
|
let max_height = cmp::min(
|
||||||
|
12. * line_height,
|
||||||
|
cmp::max(
|
||||||
|
3. * line_height,
|
||||||
|
(bounds.size.height - line_height) / 2.,
|
||||||
|
)
|
||||||
|
);
|
||||||
context_menu =
|
context_menu =
|
||||||
editor.render_context_menu(newest_selection_head, &self.style, max_height, cx);
|
editor.render_context_menu(newest_selection_head, &self.style, max_height, cx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -379,10 +379,11 @@ pub trait LspAdapter: 'static + Send + Sync {
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct CodeLabel {
|
pub struct CodeLabel {
|
||||||
|
/// The text to display.
|
||||||
pub text: String,
|
pub text: String,
|
||||||
/// Determines the syntax highlighting for the label
|
/// Syntax highlighting runs.
|
||||||
pub runs: Vec<(Range<usize>, HighlightId)>,
|
pub runs: Vec<(Range<usize>, HighlightId)>,
|
||||||
/// Which part of the label participates
|
/// The portion of the text that should be used in fuzzy filtering.
|
||||||
pub filter_range: Range<usize>,
|
pub filter_range: Range<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue