keymap_ui: Hover tooltip for context (#34290)

Closes #ISSUE

Ideally the tooltip would only appear if the context was overflowing
it's column, but for now, we just unconditionally show a tooltip so that
long contexts can be seen.

This PR also includes a change to the tooltip element, allowing for
tooltips with non-text contents which is used here for syntax
highlighting

Release Notes:

- N/A *or* Added/Fixed/Improved ...

Co-authored-by: Anthony <anthony@zed.dev>
This commit is contained in:
Ben Kunkle 2025-07-11 09:54:08 -05:00 committed by GitHub
parent 10028aaae8
commit d1a6c5d494
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 77 additions and 19 deletions

View file

@ -1015,12 +1015,24 @@ impl Render for KeymapEditor {
}
}
};
let context = binding
.context
.clone()
.map_or(gpui::Empty.into_any_element(), |context| {
context.into_any_element()
});
let context = binding.context.clone().map_or(
gpui::Empty.into_any_element(),
|context| {
let is_local = context.local().is_some();
div()
.id(("keymap context", index))
.child(context.clone())
.when(is_local, |this| {
this.tooltip(Tooltip::element({
move |_, _| {
context.clone().into_any_element()
}
}))
})
.into_any_element()
},
);
let source = binding
.source
.clone()