Fix keybind hints flickering in certain scenarios (#40927)
Closes #39172 This refactors when we resolve UI keybindings in an effort to reduce flickering whilst painting these: Previously, we would always resolve these upon creating the binding. This could lead to cases where the corresponding context was not yet available and no binding could be resolved, even if the binding was then available on the next presented frame. Following that, on the next rerender of whatever requested this keybinding, the keybind for that context would then be found, we would render that and then also win a layout shift in that process, as we went from nothing rendered to something rendered between these frames. With these changes, this now happens less often, because we only look for the keybinding once the context can actually be resolved in the window. | Before | After | | --- | --- | | https://github.com/user-attachments/assets/adebf8ac-217d-4c7f-ae5a-bab3aa0b0ee8 | https://github.com/user-attachments/assets/70a82b4b-488f-4a9f-94d7-b6d0a49aada9 | Also reduced cloning in the keymap editor in this process, since that requiered changing due to this anyway. Release Notes: - Fixed some cases where keybinds would appear with a slight delay, causing a flicker in the process
This commit is contained in:
@@ -167,7 +167,7 @@ impl Item for KeyContextView {
|
||||
}
|
||||
|
||||
impl Render for KeyContextView {
|
||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl ui::IntoElement {
|
||||
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl ui::IntoElement {
|
||||
use itertools::Itertools;
|
||||
|
||||
let key_equivalents = cx.keyboard_mapper().get_key_equivalents();
|
||||
@@ -212,7 +212,6 @@ impl Render for KeyContextView {
|
||||
.style(ButtonStyle::Filled)
|
||||
.key_binding(ui::KeyBinding::for_action(
|
||||
&zed_actions::OpenDefaultKeymap,
|
||||
window,
|
||||
cx
|
||||
))
|
||||
.on_click(|_, window, cx| {
|
||||
@@ -222,7 +221,7 @@ impl Render for KeyContextView {
|
||||
.child(
|
||||
Button::new("edit_your_keymap", "Edit Keymap File")
|
||||
.style(ButtonStyle::Filled)
|
||||
.key_binding(ui::KeyBinding::for_action(&zed_actions::OpenKeymapFile, window, cx))
|
||||
.key_binding(ui::KeyBinding::for_action(&zed_actions::OpenKeymapFile, cx))
|
||||
.on_click(|_, window, cx| {
|
||||
window.dispatch_action(zed_actions::OpenKeymapFile.boxed_clone(), cx);
|
||||
}),
|
||||
|
||||
@@ -1065,14 +1065,8 @@ impl Render for LspButton {
|
||||
.when_some(indicator, IconButton::indicator)
|
||||
.icon_size(IconSize::Small)
|
||||
.indicator_border_color(Some(cx.theme().colors().status_bar_background)),
|
||||
move |window, cx| {
|
||||
Tooltip::with_meta(
|
||||
"Language Servers",
|
||||
Some(&ToggleMenu),
|
||||
description,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
move |_window, cx| {
|
||||
Tooltip::with_meta("Language Servers", Some(&ToggleMenu), description, cx)
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user