zed/crates/gpui/src
Mikayla Maki 6f40da77b6
Fix scrolling in collab panel (#4105)
When the `List` element's state is `ListState::reset()`, it eagerly
trashes it's cached element heights in anticipation of a prompt render.
But, due to the recent `display_layer` changes, that re-render is not
always forthcoming. This is a problem for `ListState::scroll()`, which
depends on these cached elements to correctly calculate the new logical
scroll offset.

Solutions we attempted:

- Cache the element heights and continue the scroll calculation 
- This was conceptually incorrect, reset should only be called when the
underlying data has been changed, making any calculation with the old
results meaningless.
- Lazily re-compute the element heights in scroll 
- Beyond being a non-trivial refactor, this would probably also cause us
to double-render the list in a single frame, which is bad.
- Cache the scroll offset and only calculate it in paint 
- This solution felt awkward to implement and meant we can't supply
synchronous list scroll events.
- Delay resetting until paint 
- This means that all of the other APIs that `ListState` supplies would
give temporarily incorrect results, worsening the problem

Given these issues, we settled on the solution with the least
compromises: drop scroll events if the state has been `reset()` between
`paint()` and `scroll()`. This shifts the responsibility for the problem
out of the List element and into consumers of `List`, if you want
perfectly smooth scrolling then you need to use `reset()` judiciously
and prefer `splice()`.

That said, I tested this by aggressively scrolling the Collab panel, and
it seems to work as well as it did before.

This PR also includes some initial testing infrastructure for working
with input from the platform and rendered elements.

Release Notes:

- N/A
2024-01-17 14:11:34 -08:00
..
app Drop scroll events if there's been a reset 2024-01-17 13:57:16 -08:00
elements Drop scroll events if there's been a reset 2024-01-17 13:57:16 -08:00
keymap Drop scroll events if there's been a reset 2024-01-17 13:57:16 -08:00
platform Fix scrolling in collab panel (#4105) 2024-01-17 14:11:34 -08:00
text_system Merge remote-tracking branch 'origin/main' into cache 2024-01-12 14:31:13 +01:00
action.rs Add remaining tests 2024-01-10 19:39:43 -08:00
app.rs Notify global observers when removing a global 2024-01-15 17:02:20 -08:00
arena.rs Ensure ArenaRef pointers are aligned to their contained type 2024-01-10 10:36:08 -08:00
assets.rs Remove 2 suffix from gpui 2024-01-03 12:59:39 -08:00
color.rs Remove some comments 2024-01-12 20:10:40 -08:00
element.rs Add some small test code for tracking down this list bug 2024-01-16 16:52:55 -08:00
executor.rs Clean up references in doc comments (#3983) 2024-01-09 14:48:48 -05:00
geometry.rs Start on caching views 2024-01-08 19:07:20 +01:00
gpui.rs gpui: Add SharedUrl type (#3975) 2024-01-09 10:55:49 -05:00
image_cache.rs gpui: Add SharedUrl type (#3975) 2024-01-09 10:55:49 -05:00
input.rs Clean up references in doc comments (#3983) 2024-01-09 14:48:48 -05:00
interactive.rs Fix draw helper, add helper traits for selecting groupings of input events 2024-01-16 22:19:55 -08:00
key_dispatch.rs Preserve tooltips requested by cached views 2024-01-15 19:19:27 +01:00
platform.rs Fix scrolling in collab panel (#4105) 2024-01-17 14:11:34 -08:00
prelude.rs Remove 2 suffix from gpui 2024-01-03 12:59:39 -08:00
scene.rs Submit bigger primitive batches when rendering 2024-01-17 13:50:55 +01:00
shared_string.rs Remove 2 suffix from gpui 2024-01-03 12:59:39 -08:00
shared_url.rs gpui: Add SharedUrl type (#3975) 2024-01-09 10:55:49 -05:00
style.rs Prevent div background/content/border from interleaving at same z-index 2024-01-16 11:22:14 -05:00
styled.rs Make chat prettier (to my eyes at least) 2024-01-13 21:37:13 -07:00
subscription.rs Clean up references in doc comments (#3983) 2024-01-09 14:48:48 -05:00
svg_renderer.rs Remove 2 suffix from gpui 2024-01-03 12:59:39 -08:00
taffy.rs Revert "Use taffy to retrieve the parent for a given layout node" 2024-01-16 10:44:24 -05:00
test.rs Resolve more todos 2024-01-09 15:08:05 -08:00
text_system.rs Rename all_font_families to all_font_names 2024-01-16 20:32:21 +01:00
util.rs Remove 2 suffix from gpui 2024-01-03 12:59:39 -08:00
view.rs Remove some comments 2024-01-12 20:10:40 -08:00
window.rs Fix scrolling in collab panel (#4105) 2024-01-17 14:11:34 -08:00