Commit Graph
86 Commits
Author SHA1 Message Date
Piotr Osiewicz eb9959a0cf gpui: notifications now takes an entity instead of a model 2023-11-17 17:23:05 +01:00
Mikayla 9a3cd073c7 Restore a bunch of random workspace stuff 2023-11-16 23:05:28 -08:00
Max Brunsfeld e67c44a562 Fix file-reloading race condition (#3348)
### Summary

This PR fixes a bug that @as-cii and @osiewicz saw when the on-disk
contents of files changed due to running `git checkout` at the command
line. It caused a buffer's contents to diverge from the file's on disk
contents, but the buffer to show an *unmodified* status.

I've also introduced new APIs on gpui's deterministic executor, which
make it possible to write a test that reliably triggered the bug.

### Details

The bug is triggered by the following sequence of events:
1. A buffer's file changes on disk while the buffer is *unmodified*
2. Zed reloads the new content of the file
3. Before updating the buffer itself, Zed computes a *diff* between the
buffer's current contents, and the newly-loaded contents
4. While this diff is being computed, one of two things happens:
     1. the buffer changes on-disk *again*.
2. the user edits the buffer, but undoes the edit, so that the buffer
returns to an unmodified state

The bug itself was caused by a few things:
* The buffer diffing algorithm is pretty slow, because we perform a
character-wise diff
* We previously allowed multiple reload tasks to run concurrently
* When discarding an out-of-date diff, we failed to update parts of the
buffer's state (`saved_fingerprint`) which allow us to recognize that
the buffer's content differs from the file.

It was also difficult to reproduce the problem in tests, because under
deterministic execution, because it was extremely unlikely for other
tasks to make progress *after* a file had been reloaded, but *before*
the disk task has resolved. To help with testing, I introduced a pair of
executor APIs:

`spawn_labeled`, - for spawning a background task with a given *label*
`deprioritize_task` - for forcing tasks with a given label to run
*after* all other concurrent tasks.

I also made the `Model::next_event` test helper method more useful, in
that it no longer runs *until* parked in order to wait for the next
event to occur. It just steps the executor one poll at a time until the
model emits an event.

Release Notes:

- Fixed a bug that caused buffers to report incorrect modified/conflict
status when their buffers changed on disk multiple times in rapid
succession.
2023-11-16 20:19:16 -08:00
Max Brunsfeld 32979f3aca Rename deprioritize_task -> deprioritize
It applies to a family of tasks, not a task.
2023-11-16 20:03:18 -08:00
Max BrunsfeldandNathan Sobo f3b6719c76 Rename both PlatformDispatcher::poll and Executor::run_step to 'tick'
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2023-11-16 19:58:26 -08:00
Max Brunsfeld f9650b3111 Don't run until all the way until parked when waiting for a model's next event 2023-11-16 15:54:00 -08:00
Mikayla 9da0b78ead Merge branch 'main' into tabs-n-splits 2023-11-15 23:41:25 -08:00
Mikayla 78cea69172 Add focusable view and restore workspace deserialization. Partially restore split and tab functions 2023-11-15 16:36:43 -08:00
Conrad Irwin 0a51784dd0 Leaky, but better, test abstraction 2023-11-15 14:01:10 -07:00
Conrad Irwin cebc8428c8 FileFinder tests 2023-11-15 13:16:28 -07:00
Conrad Irwin 91b54b352b Add command palette tests and simulate_keystrokes 2023-11-14 23:22:51 -07:00
Mikayla Maki df64a3c701 Not working yet file-finder2 (#3321)
Porting file_finder

Release Notes:

- N/A
2023-11-14 15:22:59 -08:00
Max Brunsfeld ca63a99736 Enable tests in project panel 2 (#3325) 2023-11-14 15:02:51 -08:00
Max Brunsfeld 860959fe13 Implement simulated prompts in TestPlatform 2023-11-14 14:56:50 -08:00
Mikayla 6b25841e2a WIP 2023-11-14 14:48:34 -08:00
Conrad Irwin 3b01a032ba In the middle of stuff 2023-11-14 14:38:23 -07:00
Max Brunsfeld 123faed5b0 Re-enable all project panel tests
Some are still failing.
2023-11-14 12:45:46 -08:00
Mikayla 3419aaf17e Fix several shutdown related bugs 2023-11-14 11:42:58 -08:00
Mikaylaandconrad a4e9fea133 WIP
co-authored-by: conrad <conrad.irwin@zed.dev>
2023-11-13 15:53:04 -08:00
Mikayla 0e3fd92bd0 Get editor tests compiling 2023-11-13 12:10:14 -08:00
Mikayla 656eb9d455 WIP 2023-11-09 00:18:00 -08:00
Mikayla 43eb7f28d1 checkpoint 2023-11-08 23:16:04 -08:00
Mikayla 7a7ef1025d Add Context::read_window, WindowHandle::root, and change ViewContext.view() to return a reference 2023-11-08 22:11:19 -08:00
Mikayla 2c67cc80ba Merge branch 'main' into event-emitter 2023-11-08 20:10:38 -08:00
Mikayla 26fc36ee0e First pass at allowing multiple event types to be emitted by an entity 2023-11-08 16:34:38 -08:00
Conrad Irwin 1b9f76c01d Refactor GoToLine to use cx.observe_new_views() 2023-11-08 16:23:05 -07:00
Mikayla 9b30f490c7 Merge branch 'main' into add-collab-tests 2023-11-08 09:57:08 -08:00
Max Brunsfeld 69eb49a2ed Merge branch 'main' into picker 2023-11-07 09:34:57 -08:00
Conrad Irwin 8e799b6e22 Flesh out gpui2 test support 2023-11-06 21:05:11 -07:00
Mikayla ea6755b1ca Checkpoint 2023-11-06 14:26:10 -08:00
Mikayla e1525e2b47 Get collab2 green 2023-11-03 18:01:06 -07:00
Max BrunsfeldandMarshall b085569b46 Add channel2 crate
Co-authored-by: Marshall <marshall@zed.dev>
2023-11-03 10:41:41 -07:00
Nathan SoboandJulia Risley 04a8ee222b Enforce a Send bound on next frame callbacks
This required using mpsc channels to invoke frame callbacks on the
main thread and send the receiver to the platform display link.

Co-Authored-By: Julia Risley <julia@zed.dev>
2023-11-02 12:01:22 -06:00
Marshall Bowers 0e1d2fdf21 Checkpoint: Narrow down error 2023-11-02 12:47:06 -04:00
Marshall Bowers 66e4d75e6f Checkpoint: Reproduction with Avatar story 2023-11-02 12:34:40 -04:00
Antonio Scandurra 32db64a049 Introduce more GPUI2 APIs needed for transitioning the workspace 2023-11-02 10:54:33 +01:00
Antonio Scandurra d5f0e91faa Remove stray todo 2023-11-02 09:56:45 +01:00
Antonio Scandurra 64ad8943ba Remove more Send bounds and simplify view rendering 2023-11-02 09:44:16 +01:00
Nathan Sobo 57dfc50687 Get language2 tests passing by not blocking on a foreground task 2023-11-01 21:04:17 -06:00
Nathan Sobo 53066df522 Get project2 tests green 2023-11-01 20:14:40 -06:00
Max Brunsfeld 401ddc6f49 WIP - flush_fs_events 2023-11-01 17:45:38 -07:00
Max BrunsfeldandNathan Sobo 6ee93125d0 Fix hangs in new dispatcher
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2023-11-01 17:11:42 -07:00
Nathan Sobo 11b6d9e33a Split out a foreground and background executor 2023-11-01 13:53:45 -06:00
57ffa8201e Start removing the Send impl for App
Co-authored-by: Antonio <antonio@zed.dev>
Co-authored-by: Nathan <nathan@zed.dev>
2023-11-01 13:53:45 -06:00
Max BrunsfeldandMarshall 291d35f337 Merge branch 'main' into zed2-project-test
Co-authored-by: Marshall <marshall@zed.dev>
2023-10-31 11:50:56 -07:00
Conrad Irwin 0e9a82711c Actually deliver test events to subscribers 2023-10-31 16:04:33 +00:00
Conrad Irwin b8e007c6ec Call flush_effects in test context update()
In gpui1 we used to do this even outside of top-level contexts, but not
sure we should make tests work that differently to the main app.
2023-10-31 14:24:12 +00:00
Conrad Irwin 3e5379526e Fix entity map drop behavior
The entity map needs to be able to distinguish between the case when
the entity_id is waiting to be dropped, and when it is completely gone.

Before 8bc207141, it assumed that entity_ids in dropped_entity_ids could
be re-used. This caused `take_dropped` to error because the slot had
been overwritten. The fix there caused weak handles to allow upgrading
a reference count from 0, which could resurrect items in
`dropped_entity_ids` which caused them to be dropped twice.

We could allow weak items to upgrade from 0, and delete from
dropped_entity_ids, but that seemed more complicated than necessary.
2023-10-31 13:09:35 +00:00
Mikayla f5b13071f1 experiment with a way to recover the any entities when downcasting fails 2023-10-30 18:08:38 -07:00
Mikayla 6f1197e00c Change model to downcast with ownership 2023-10-30 18:00:37 -07:00