Commit Graph

182 Commits

Author SHA1 Message Date
Marshall Bowers
ec0cff0e1a
Add map method to Components (#3210)
This PR adds a `map` method to the `Component` trait.

`map` is a fully-generalized form of `when`, as `when` can be expressed
in terms of `map`:

```rs
div().map(|this| if condition { then(this) } else { this })
```

This allows us to take advantage of Rust's pattern matching when
building up conditions:

```rs
// Before
div()
    .when(self.current_side == PanelSide::Left, |this| this.border_r())
    .when(self.current_side == PanelSide::Right, |this| {
        this.border_l()
    })
    .when(self.current_side == PanelSide::Bottom, |this| {
        this.border_b().w_full().h(current_size)
    })

// After
div()
    .map(|this| match self.current_side {
        PanelSide::Left => this.border_r(),
        PanelSide::Right => this.border_l(),
        PanelSide::Bottom => this.border_b().w_full().h(current_size),
    })
```

Release Notes:

- N/A
2023-11-02 11:39:40 -04:00
Antonio Scandurra
76c675a63b 💄 2023-11-02 10:57:29 +01:00
Antonio Scandurra
32db64a049 Introduce more GPUI2 APIs needed for transitioning the workspace 2023-11-02 10:54:33 +01:00
Antonio Scandurra
9c7b45f38b Add back Send and Sync to AssetSource 2023-11-02 09:58:53 +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
db9ccd7f34 Merge remote-tracking branch 'origin/main' into gpui2-no-send 2023-11-01 21:10:31 -06: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 Brunsfeld
6ee93125d0 Fix hangs in new dispatcher
Co-authored-by: Nathan Sobo <nathan@zed.dev>
2023-11-01 17:11:42 -07:00
Conrad Irwin
90facc051a beautiful diff 2023-11-01 15:31:37 -06:00
Conrad Irwin
f415a37a3d
Uncomment project2 tests (#3200) 2023-11-01 20:27:53 +00:00
Conrad Irwin
cd10ba9e06 Use run_until_parked instead of blocked in tests 2023-11-01 14:27:25 -06:00
Nathan Sobo
3f34a8e7ec Checkpoint 2023-11-01 14:00:26 -06:00
Nathan Sobo
11b6d9e33a Split out a foreground and background executor 2023-11-01 13:53:45 -06:00
Max Brunsfeld
dd1a2a9e44 wip 2023-11-01 13:53:45 -06:00
Max Brunsfeld
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
Marshall Bowers
b910bbf002
Add ui_font_size setting (#3199)
This PR adds a new `ui_font_size` setting that can be used to control
the scale of the entire UI.

We use the value in this setting to set the base rem size of the window.

Release Notes:

- N/A
2023-11-01 13:11:12 -04:00
Julia
795369a1e3 Port multi_buffer to gpui2 2023-10-31 18:34:36 -04:00
Max Brunsfeld
291d35f337 Merge branch 'main' into zed2-project-test
Co-authored-by: Marshall <marshall@zed.dev>
2023-10-31 11:50:56 -07:00
Antonio Scandurra
66b520a513 Call initialize on the rendered element on AnyView 2023-10-31 17:17:42 +01:00
Conrad Irwin
8db6b78fdd Implement start/finish waiting for gpui2
I'm not sure these are strictly necessary, but it will make porting
tests easier to have them.
2023-10-31 16:14:10 +00:00
Conrad Irwin
0e9a82711c Actually deliver test events to subscribers 2023-10-31 16:04:33 +00:00
Conrad Irwin
81f8e81e48 Fix block to allow for sync progress 2023-10-31 15:57:01 +00:00
Antonio Scandurra
0aa9c6b61d Introduce AnyWeakView
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2023-10-31 16:19:46 +01:00
Antonio Scandurra
7b6514b178 Simplify AnyView
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2023-10-31 16:16:30 +01: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
Antonio Scandurra
88875fd006
Zed2 entities (#3189)
Adds an `Entity` trait for abstracting over `View`s and `Model`s, and
implements it for the `subscribe()` and `observe()` APIs.

The last commit also includes a fun experiment I added, using the
`Result` type to return the owned model handles back to the caller in
the case of downcast failure, inspired by the `binary_search*` methods.
2023-10-31 10:11:25 +01:00
Julia
db34de6be4 Port zed/src/languages to zed2 2023-10-30 21:52:29 -04: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
Mikayla
327a2f9967
Add the entity trait and implement for models, views, subscriptions, and observations 2023-10-30 17:50:21 -07:00
Max Brunsfeld
30dffbb409 Introduce a Render trait, make views implement it
Don't pass a render function separately from the view.

Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Antonio <as-cii@zed.dev>
2023-10-30 15:19:40 -07:00
Antonio Scandurra
0128079de0 WIP 2023-10-30 20:36:48 +01:00
Antonio Scandurra
bc4f8fbf4e Rename other references from "handle" to "model"
Co-Authored-By: Max <max@zed.dev>
Co-Authored-By: Mikayla <mikayla@zed.dev>
2023-10-30 19:54:32 +01:00
Antonio Scandurra
1a54ac0d69 Rename Handle to Model 2023-10-30 19:44:01 +01:00
Antonio Scandurra
25e882d72a Remove randomness from GPUI2 block_with_timeout 2023-10-30 12:10:55 +01:00
Nathan Sobo
e27427dce8 Merge branch 'gpui2-docs' into zed2 2023-10-27 17:07:28 -06:00
Nathan Sobo
f88ca2e7da Add docs for window.rs, but still incomplete 2023-10-27 22:29:59 +02:00
Nathan Sobo
ad7c49e4bb Add doc comments to app.rs 2023-10-27 21:19:48 +02:00
Conrad Irwin
67ecc2fe04 Comment out failing gpui2 test 2023-10-27 11:24:23 +02:00
Conrad Irwin
af0c010b4a Remove deadlock from gpui2 pasteboard 2023-10-27 11:14:13 +02:00
Conrad Irwin
5f5234c5da Fix fs2 tests 2023-10-27 10:51:36 +02:00
Conrad Irwin
c1904b493b Fix cargo fmt 2023-10-27 10:44:57 +02:00
Nathan Sobo
a1c3826858 Add View::update which provides a ViewContext 2023-10-26 19:41:42 +02:00
Conrad Irwin
adc426b668 v1 2023-10-26 18:19:57 +02:00
Antonio Scandurra
8e3314e680 WIP 2023-10-26 18:17:45 +02:00
Antonio Scandurra
637cff3ebd WIP 2023-10-26 17:15:19 +02:00