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:
@@ -948,8 +948,8 @@ impl Render for PanelButtons {
|
||||
}
|
||||
})
|
||||
.when(!is_active, |this| {
|
||||
this.tooltip(move |window, cx| {
|
||||
Tooltip::for_action(tooltip.clone(), &*action, window, cx)
|
||||
this.tooltip(move |_window, cx| {
|
||||
Tooltip::for_action(tooltip.clone(), &*action, cx)
|
||||
})
|
||||
})
|
||||
}),
|
||||
|
||||
@@ -75,7 +75,7 @@ impl Focusable for InvalidItemView {
|
||||
}
|
||||
|
||||
impl Render for InvalidItemView {
|
||||
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl gpui::IntoElement {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl gpui::IntoElement {
|
||||
let abs_path = self.abs_path.clone();
|
||||
v_flex()
|
||||
.size_full()
|
||||
@@ -103,11 +103,7 @@ impl Render for InvalidItemView {
|
||||
cx.open_with_system(&abs_path);
|
||||
})
|
||||
.style(ButtonStyle::Outlined)
|
||||
.key_binding(KeyBinding::for_action(
|
||||
&OpenWithSystem,
|
||||
window,
|
||||
cx,
|
||||
)),
|
||||
.key_binding(KeyBinding::for_action(&OpenWithSystem, cx)),
|
||||
),
|
||||
)
|
||||
}),
|
||||
|
||||
@@ -315,19 +315,17 @@ impl Render for LanguageServerPrompt {
|
||||
)
|
||||
.child(
|
||||
IconButton::new(close_id, close_icon)
|
||||
.tooltip(move |window, cx| {
|
||||
.tooltip(move |_window, cx| {
|
||||
if suppress {
|
||||
Tooltip::for_action(
|
||||
"Suppress.\nClose with click.",
|
||||
&SuppressNotification,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
} else {
|
||||
Tooltip::for_action(
|
||||
"Close.\nSuppress with shift-click.",
|
||||
&menu::Cancel,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
}
|
||||
@@ -556,23 +554,21 @@ impl RenderOnce for NotificationFrame {
|
||||
this.on_modifiers_changed(move |_, _, cx| cx.notify(entity))
|
||||
.child(
|
||||
IconButton::new(close_id, close_icon)
|
||||
.tooltip(move |window, cx| {
|
||||
.tooltip(move |_window, cx| {
|
||||
if suppress {
|
||||
Tooltip::for_action(
|
||||
"Suppress.\nClose with click.",
|
||||
&SuppressNotification,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
} else if show_suppress_button {
|
||||
Tooltip::for_action(
|
||||
"Close.\nSuppress with shift-click.",
|
||||
&menu::Cancel,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
} else {
|
||||
Tooltip::for_action("Close", &menu::Cancel, window, cx)
|
||||
Tooltip::for_action("Close", &menu::Cancel, cx)
|
||||
}
|
||||
})
|
||||
.on_click({
|
||||
|
||||
@@ -2730,12 +2730,11 @@ impl Pane {
|
||||
.map(|this| {
|
||||
if is_active {
|
||||
let focus_handle = focus_handle.clone();
|
||||
this.tooltip(move |window, cx| {
|
||||
this.tooltip(move |_window, cx| {
|
||||
Tooltip::for_action_in(
|
||||
end_slot_tooltip_text,
|
||||
end_slot_action,
|
||||
&focus_handle,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
@@ -3038,9 +3037,7 @@ impl Pane {
|
||||
.disabled(!self.can_navigate_backward())
|
||||
.tooltip({
|
||||
let focus_handle = focus_handle.clone();
|
||||
move |window, cx| {
|
||||
Tooltip::for_action_in("Go Back", &GoBack, &focus_handle, window, cx)
|
||||
}
|
||||
move |_window, cx| Tooltip::for_action_in("Go Back", &GoBack, &focus_handle, cx)
|
||||
});
|
||||
|
||||
let navigate_forward = IconButton::new("navigate_forward", IconName::ArrowRight)
|
||||
@@ -3056,8 +3053,8 @@ impl Pane {
|
||||
.disabled(!self.can_navigate_forward())
|
||||
.tooltip({
|
||||
let focus_handle = focus_handle.clone();
|
||||
move |window, cx| {
|
||||
Tooltip::for_action_in("Go Forward", &GoForward, &focus_handle, window, cx)
|
||||
move |_window, cx| {
|
||||
Tooltip::for_action_in("Go Forward", &GoForward, &focus_handle, cx)
|
||||
}
|
||||
});
|
||||
|
||||
@@ -3660,11 +3657,10 @@ fn default_render_tab_bar_buttons(
|
||||
.on_click(cx.listener(|pane, _, window, cx| {
|
||||
pane.toggle_zoom(&crate::ToggleZoom, window, cx);
|
||||
}))
|
||||
.tooltip(move |window, cx| {
|
||||
.tooltip(move |_window, cx| {
|
||||
Tooltip::for_action(
|
||||
if zoomed { "Zoom Out" } else { "Zoom In" },
|
||||
&ToggleZoom,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
|
||||
@@ -319,13 +319,7 @@ impl ThemePreview {
|
||||
.style(ButtonStyle::Transparent)
|
||||
.tooltip(move |window, cx| {
|
||||
let name = name.clone();
|
||||
Tooltip::with_meta(
|
||||
name,
|
||||
None,
|
||||
format!("{:?}", color),
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
Tooltip::with_meta(name, None, format!("{:?}", color), cx)
|
||||
}),
|
||||
)
|
||||
})),
|
||||
|
||||
Reference in New Issue
Block a user