Visual Studio Code, rebuilt in Rust
Rust
fix(gpui): keep hover styles while typing under a still pointer
rokartur00ea1602a9ff
diff --git a/native/vendor/gpui-fast/crates/gpui/src/elements/div.rs b/native/vendor/gpui-fast/crates/gpui/src/elements/div.rsindex 1a153603abc..9d2deff5ea7 100644--- a/native/vendor/gpui-fast/crates/gpui/src/elements/div.rs+++ b/native/vendor/gpui-fast/crates/gpui/src/elements/div.rs@@ -4793,7 +4793,7 @@ mod tests {}#[gpui::test]- fn default_hover_listener_ends_after_key_press(cx: &mut TestAppContext) {+ fn default_hover_listener_stays_hovered_after_key_press(cx: &mut TestAppContext) {let hover_transitions = Rc::new(RefCell::new(Vec::new()));let window = cx.add_window({let hover_transitions = hover_transitions.clone();@@ -4814,7 +4814,8 @@ mod tests {key_down(cx, any_window, "a");cx.update_window(any_window, |_, window, cx| window.draw(cx).clear(cx)).unwrap();- assert_eq!(*hover_transitions.borrow(), [true, false]);+ // VSRustium: keyboard input no longer hides hover (hover_freeze.rs `hides_hover`).+ assert_eq!(*hover_transitions.borrow(), [true]);}struct HoverListenerModeLayoutTestView {diff --git a/native/vendor/gpui-fast/crates/gpui/src/fast/layers/hover_freeze.rs b/native/vendor/gpui-fast/crates/gpui/src/fast/layers/hover_freeze.rsindex 16366bf345f..9ca5498b386 100644--- a/native/vendor/gpui-fast/crates/gpui/src/fast/layers/hover_freeze.rs+++ b/native/vendor/gpui-fast/crates/gpui/src/fast/layers/hover_freeze.rs@@ -321,14 +321,14 @@ fn within_slop(anchor: Point<Pixels>, position: Point<Pixels>) -> bool {/// Whether hover reads as nothing for a hitbox the pointer has not captured,/// for [`crate::HitboxId::is_hovered`] and what a retained subtree records of-/// it: after keyboard input, as upstream has it, and while a frame is drawn-/// with hover held still.+/// it: while a frame is drawn with hover held still. Keyboard input does not+/// hide it (VSRustium: CSS `:hover` follows only the pointer).////// Event dispatch is not drawing. A mouse listener asks `is_hovered` before it/// runs, so holding hover there too would drop a click made under a still/// pointer right after the wheel.pub(crate) fn hides_hover(window: &Window) -> bool {- window.last_input_was_keyboard() || (!window.invalidator.not_drawing() && frozen(window))+ !window.invalidator.not_drawing() && frozen(window)}/// Whether a frame being drawn leaves hover listeners as they were, for anydiff --git a/native/vendor/gpui-fast/crates/gpui/src/fast/layers/lists.rs b/native/vendor/gpui-fast/crates/gpui/src/fast/layers/lists.rsindex ad539f0a2ee..9501a70efda 100644--- a/native/vendor/gpui-fast/crates/gpui/src/fast/layers/lists.rs+++ b/native/vendor/gpui-fast/crates/gpui/src/fast/layers/lists.rs@@ -697,7 +697,7 @@ fn stale_rows(let rows_at = range.start.hitboxes_index..range.end.hitboxes_index;let hit = foretold_hit_test(window, rows, rows_at, translation, viewport);let hovered = |id: HitboxId| {- window.captured_hitbox == Some(id) || (!window.last_input_was_keyboard() && hit.hovers(id))+ window.captured_hitbox == Some(id) || hit.hovers(id)};rows.iter().filter(|(_, row)| row.hovers.iter().any(|(id, was)| hovered(*id) != *was))diff --git a/native/vendor/gpui-fast/crates/gpui/src/window.rs b/native/vendor/gpui-fast/crates/gpui/src/window.rsindex c710e8af93a..dab26dc5d58 100644--- a/native/vendor/gpui-fast/crates/gpui/src/window.rs+++ b/native/vendor/gpui-fast/crates/gpui/src/window.rs@@ -787,8 +787,8 @@ impl HitboxId {}impl HitboxId {- /// Checks if the hitbox with this ID is currently hovered. Returns `false` during keyboard- /// input modality so that keyboard navigation suppresses hover highlights. Except when handling+ /// Checks if the hitbox with this ID is currently hovered, also during keyboard input modality+ /// (VSRustium: CSS `:hover` follows only the pointer). Except when handling/// `ScrollEvent`, this is typically what you want when determining whether to handle mouse/// events or paint hover styles.///@@ -858,15 +858,14 @@ pub struct Hitbox {}impl Hitbox {- /// Checks if the hitbox is currently hovered. Returns `false` during keyboard input modality- /// so that keyboard navigation suppresses hover highlights. Except when handling+ /// Checks if the hitbox is currently hovered. Like CSS `:hover`, keyboard input does not+ /// suppress it (VSRustium: VS Code keeps hover styles while typing). Except when handling/// `ScrollEvent`, this is typically what you want when determining whether to handle mouse/// events or paint hover styles.////// This can return `false` even when the hitbox contains the mouse, if a hitbox in front of/// this sets `HitboxBehavior::BlockMouse` (`InteractiveElement::occlude`) or- /// `HitboxBehavior::BlockMouseExceptScroll` (`InteractiveElement::block_mouse_except_scroll`),- /// or if the current input modality is keyboard (see [`Window::last_input_was_keyboard`]).+ /// `HitboxBehavior::BlockMouseExceptScroll` (`InteractiveElement::block_mouse_except_scroll`).////// Handling of `ScrollEvent` should typically use `should_handle_scroll` instead./// Concretely, this is due to use-cases like overlays that cause the elements under to be