Commit Graph
57 Commits
Author SHA1 Message Date
4700d33728 Fix flickering (#9012)
See https://zed.dev/channel/gpui-536

Fixes https://github.com/zed-industries/zed/issues/9010
Fixes https://github.com/zed-industries/zed/issues/8883
Fixes https://github.com/zed-industries/zed/issues/8640
Fixes https://github.com/zed-industries/zed/issues/8598
Fixes https://github.com/zed-industries/zed/issues/8579
Fixes https://github.com/zed-industries/zed/issues/8363
Fixes https://github.com/zed-industries/zed/issues/8207


### Problem

After transitioning Zed to GPUI 2, we started noticing that interacting
with the mouse on many UI elements would lead to a pretty annoying
flicker. The main issue with the old approach was that hover state was
calculated based on the previous frame. That is, when computing whether
a given element was hovered in the current frame, we would use
information about the same element in the previous frame.

However, inspecting the previous frame tells us very little about what
should be hovered in the current frame, as elements in the current frame
may have changed significantly.

### Solution

This pull request's main contribution is the introduction of a new
`after_layout` phase when redrawing the window. The key idea is that
we'll give every element a chance to register a hitbox (see
`ElementContext::insert_hitbox`) before painting anything. Then, during
the `paint` phase, elements can determine whether they're the topmost
and draw their hover state accordingly.

We are also removing the ability to give an arbitrary z-index to
elements. Instead, we will follow the much simpler painter's algorithm.
That is, an element that gets painted after will be drawn on top of an
element that got painted earlier. Elements can still escape their
current "stacking context" by using the new `ElementContext::defer_draw`
method (see `Overlay` for an example). Elements drawn using this method
will still be logically considered as being children of their original
parent (for keybinding, focus and cache invalidation purposes) but their
layout and paint passes will be deferred until the currently-drawn
element is done.

With these changes we also reworked geometry batching within the
`Scene`. The new approach uses an AABB tree to determine geometry
occlusion, which allows the GPU to render non-overlapping geometry in
parallel.

### Performance

Performance is slightly better than on `main` even though this new
approach is more correct and we're maintaining an extra data structure
(the AABB tree).


![before_after](https://github.com/zed-industries/zed/assets/482957/c8120b07-1dbd-4776-834a-d040e569a71e)

Release Notes:

- Fixed a bug that was causing popovers to flicker.

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Thorsten <thorsten@zed.dev>
2024-03-11 10:45:57 +01:00
Kirill Bulatov 625c9d8980 Remove some todo!'s 2024-01-09 11:36:36 +02:00
Max BrunsfeldandMikayla 588976d27a Remove 2 suffix for editor
Co-authored-by: Mikayla <mikayla@zed.dev>
2024-01-03 10:58:57 -08:00
Julia bfdff4e2e0 When navigating diagnostics, skip diagnostic containing cursor
Slightly unfortunate but prevents an issue with weirdly overlapping
diagnostics causing the cursor to bounce between them
2023-10-24 17:56:56 +02:00
Joseph Lyons 7c60f636d5 Fix typos 2023-06-02 22:02:19 -04:00
Nathan Sobo de9bf6dfbd Merge MutableAppContext into AppContext
There may have been a good reason for the difference at some point, or I was
still learning Rust. But now it's just &mut AppContext vs &AppContext.
2023-04-06 15:49:03 -06:00
Antonio Scandurra 4d915f4530 Don't make fonts::Features Copy 2023-03-17 13:54:56 +01:00
Antonio Scandurra b2c733baab WIP: Allow specifying font features in the editor
This just lays the foundation for threading through a `fonts::Features`
struct, but it's not used yet.
2023-03-17 09:51:36 +01:00
K Simmons d2494822b0 Add assertion context manager to TestAppContext and convert existing vim tests to use neovim backed test context 2022-10-10 14:46:07 -07:00
K Simmons 515c1ea123 Fixed some neovim test context issues, added repeated commands in vim mode, and ported some tests to use the neovim testing strategy 2022-10-08 21:52:07 -07:00
K Simmons 3b9b2cd443 Add tests for the dock 2022-09-13 19:18:05 -07:00
K Simmons b88abcacac WIP dock split button and default item 2022-09-11 15:31:44 -07:00
ForLoveOfCatsandMax Brunsfeld 8583320e9b Add test for pending selection influence on go-to links
Co-authored-by: Max Brunsfeld <max@zed.dev>
2022-08-18 18:34:01 -04:00
Max Brunsfeld 89a645ee11 Add docs to some EditorTestContext methods that use marked text 2022-08-04 11:25:09 -07:00
Max Brunsfeld 26fdaeb92b Use new marked ranges format whenever we don't need overlapping ranges 2022-08-04 10:23:03 -07:00
Max Brunsfeld afcf5fc95b Update vim mode tests to use new marked text format 2022-08-03 17:52:34 -07:00
Max Brunsfeld eabd9c02e5 Update marked text helpers to use more distinctive characters for markers 2022-08-03 16:45:16 -07:00
Max Brunsfeld ab037fe844 Simulate calling of text-insertion APIs in TestAppContext::dispatch_keystroke 2022-07-25 12:20:12 -07:00
Antonio Scandurra ca3e73106c Merge branch 'main' into ime-support-2 2022-07-25 10:47:49 +02:00
Max Brunsfeld 372c3eed52 Adjust editor tests to use input APIs instead of key events 2022-07-21 21:36:40 -07:00
Antonio Scandurra 101a0663d3 Remove input from KeyDownEvent 2022-07-21 14:29:27 +02:00
K Simmons b85b2a90aa address warnings 2022-07-20 19:02:33 -07:00
K Simmons 02a47d962e add test coverage for diagnostic popover 2022-07-20 19:02:33 -07:00
Keith Simmons 7f3018c3f6 add show_completions_on_input setting to disable popping the completions menu automatically 2022-07-13 14:23:49 -07:00
Antonio Scandurra afc8e9050c Merge pull request #1252 from zed-industries/plugin
Language Server WebAssembly Plugin Integration (Part 2)
2022-07-12 11:04:20 +02:00
Isaac Clayton ec327a30c3 Fix minor issues pointed out in the review 2022-07-11 15:54:03 +02:00
Mikayla Maki 2a6e23ff28 Hoisted assert clipboard into TestAppContext 2022-07-07 14:55:25 -07:00
Isaac Clayton 895747476f Done! Finish transition to async, very close to merging 2022-07-07 16:21:20 +02:00
Isaac Clayton 39fdbc593b Fix most warnings 2022-07-07 16:19:49 +02:00
Isaac Clayton 6585daccf9 Further unpropogate async 2022-07-07 16:16:58 +02:00
Keith Simmons 1f3dc2f534 highlight both brackets, only when empty selection, and add test 2022-07-05 15:19:05 -07:00
Keith Simmons 92ab107fc9 working jump to definition with tests 2022-06-24 15:09:31 -07:00
Max Brunsfeld fb2a7787a1 Clone fold and selection state correctly when splitting an editor 2022-06-23 13:15:50 -07:00
Keith Simmons e21d1b1acb Merge fix 2022-06-09 17:07:32 -07:00
Keith Simmons 3cec157335 fix compile error in EditorLspTestContext 2022-06-09 17:03:45 -07:00
Keith Simmons 8378590d57 Test fixes 2022-06-09 17:03:45 -07:00
Keith Simmons 722023e347 test and build fixes 2022-06-09 17:03:45 -07:00
Keith Simmons dddfc7beae Add hover test and tweak dismiss logic 2022-06-09 17:03:45 -07:00
Max Brunsfeld 7bb7187619 Add tests and fix bugs for editor indent/outdent commands w/ hard tabs 2022-06-09 10:26:09 -07:00
Keith Simmons e104cb94e7 fix bug in marked_range utils 2022-05-26 17:02:05 -07:00
Keith Simmons 98f9575653 WIP 2022-05-26 17:02:05 -07:00
Keith Simmons c3a36e6d8a Rename selected_ranges and selected_display_ranges to remove redundant selected 2022-05-13 15:55:27 -07:00
Keith Simmons de9dc27980 store buffer and display_map model handles on selections collection 2022-05-13 15:55:27 -07:00
Keith Simmons db0a9114c2 Passing tests and removed local argument. Also pulled autoscroll argument out to change_selections 2022-05-13 15:55:27 -07:00
Keith Simmons c9dcfff607 Move selection helpers to SelectionCollection, add update_anchor_selections, add a number of invariant preserving mutation functions to the MutableSelectionCollection 2022-05-13 15:55:17 -07:00
Keith SimmonsandMax Brunsfeld 67b15ee037 Use language specific tabsize in editor commands
Co-authored-by: Max Brunsfeld <max@zed.dev>
2022-04-06 15:10:29 -07:00
Keith Simmons 1812480cbb Tab size is pulled properly from settings instead of hardcoded 2022-04-06 10:23:37 -07:00
Keith Simmons 1a29180185 Fixed issue with enabling and disabling vim mode dynamically
Also added indoc and marked text utility to vim tests to improve readability
2022-03-25 20:10:52 -07:00
Keith SimmonsandNathan Sobo 0aaf270650 Add clip_to_line_end to display_map/snapshot and set it to ensure vim positioning in normal mode
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2022-03-25 20:10:52 -07:00
Max BrunsfeldandKeith Simmons ff4bdb3114 Fix incorrect highlighting when an empty range is highlighted via the DisplayMap
Co-Authored-By: Keith Simmons <keith@zed.dev>
2022-03-23 18:20:55 -07:00