Commit Graph

1652 Commits

Author SHA1 Message Date
Mikayla Maki
b9218ae80b
Add module documentation to GPUI and make gpui.rs example compile (#4241)
[[PR Description]]

Release Notes:

- N/A
2024-01-24 05:19:15 -08:00
Antonio Scandurra
92b0184036 Load images in the background 2024-01-24 13:15:31 +01:00
Antonio Scandurra
526ea40005
Log if element arena allocation is >80% (#4246)
We recently doubled the size of the `ELEMENT_ARENA` after someone ran
into a panic due to the arena running out of space.

This adds some logging so that we can hopefully develop a better
understanding of when the element area's allocation is elevated.

Release Notes:

- N/A
2024-01-24 12:48:05 +01:00
Thorsten Ball
e01850642f
Cache font-missing result to avoid unnecessary lookups (#4245)
This fixes the performance problem we saw in
https://github.com/zed-industries/community/issues/2405.

In a trace we could see that if a font is missing we'd constantly look
it up and never cache that it's missing.

This changes that and does cache the font-is-missing result.

Drawback is that one would need to restart Zed after installing a
missing font that was configured in settings. That seems acceptable for
now, though.

Release Notes:

- Improved rendering performance when configured fonts are missing on
the system.
2024-01-24 11:07:11 +01:00
Thorsten Ball
18f5752f04 Log if element arena allocation is >80%
We recently doubled the size of the `ELEMENT_ARENA` after someone ran
into a panic due to the arena running out of space.

This adds some logging so that we can hopefully develop a better
understanding of when the element area's allocation is elevated.

Co-authored-by: Antonio <antonio@zed.dev>
2024-01-24 11:03:28 +01:00
Thorsten Ball
4800991f28 Cache font-missing result to avoid unnecessary lookups
This fixes the performance problem we saw in https://github.com/zed-industries/community/issues/2405.

In a trace we could see that if a font is missing we'd constantly look
it up and never cache that it's missing.

This changes that and does cache the font-is-missing result.

Drawback is that one would need to restart Zed after installing a
missing font that was configured in settings. That seems acceptable for
now, though.

Co-authored-by: Antonio <antonio@zed.dev>
2024-01-24 10:38:38 +01:00
Antonio Scandurra
b640e0e7af Increase capacity of element arena to 8MB
This fixes a panic we just saw on nightly. It's the first time we
see this panic, so I think it's pretty safe to assume having twice as
much capacity will fix it.
2024-01-24 10:14:26 +01:00
Mikayla
ce0ff819f9
Fix more tests 2024-01-23 21:49:05 -08:00
Mikayla
fa6acc385f
Add note about discord 2024-01-23 21:41:06 -08:00
Mikayla
ce7cd5a077
Copy GPUI documentation to README 2024-01-23 21:35:01 -08:00
Mikayla
d80959d64e
Add module documentation to GPUI and make gpui.rs example compile 2024-01-23 21:29:12 -08:00
Marshall Bowers
c07e416dc0
Clean up gpui docs (#4240)
This PR does some cleanup of the `gpui` docs, making sure we're linking
things appropriately and following good Rust documentation style.

Release Notes:

- N/A
2024-01-23 23:20:05 -05:00
Mikayla Maki
1aa02ac4b6
Ensure that notify observations are sent during Window::draw() (#4236)
This PR fixes a bug in GPUI where the observation API would not be
triggered if a focus event caused a `notify()`

Release Notes:

- N/A
2024-01-23 20:17:34 -08:00
Mikayla
83363008f9
Call notify observers during Window::draw() 2024-01-23 16:52:34 -08:00
Marshall Bowers
63d86fb137
Add barebones GPUI README (#4235)
This PR adds a barebones README to the `gpui` crate, just so folks have
somewhere to land on when we link them here from
[gpui.rs](https://www.gpui.rs/).

We can flesh this out as we go.

Release Notes:

- N/A
2024-01-23 19:22:49 -05:00
Mikayla Maki
9f6072c6b6
Revert "Improve completion, action and shared project popovers' layout" 2024-01-23 15:26:11 -08:00
Kirill Bulatov
bf35b78380 Allow both action and completion lists to occupy max width and height of its element 2024-01-23 22:42:06 +02:00
Julia
c4a028d38d
Make was_top_layer_under_active_drag more closely match logic of was_top_layer (#4222)
Release Notes:

- N/A
2024-01-23 14:04:49 -05:00
Julia
21d6751c48 Make was_top_layer_under_active_drag more closely match logic of was_top_layer
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2024-01-23 12:44:23 -05:00
Conrad Irwin
61dfec2b75
Add keymatch modes so terminal can have cmd-k (#4219)
This isn't my favorite idea of a fix, but it does work for now, and it
seems likely the terminal will need to configure other aspects of action
dispatch in the future.

In the future we should explore making it possible to do this via the
keymap, either by making disabling bindings more robust; or by having a
way to indicate immediate mode per binding.

Release Notes:

- Fixed a bug where cmd-k in terminal took 1s
2024-01-23 10:23:45 -07:00
Piotr Osiewicz
21e6b09361
Remove license-file from Cargo.toml as it is apparently redundant (#4218)
Release Notes:

- N/A
2024-01-23 17:40:30 +01:00
Conrad Irwin
056da0a0f1 Add keymatch modes so terminal can have cmd-k
This isn't my favorite idea of a fix, but it does work for now, and it
seems likely the terminal will need to configure other aspects of action
dispatch in the future.

In the future we should explore making it possible to do this via the
keymap, either by making disabling bindings more robust; or by having a
way to indicate immediate mode per binding.
2024-01-23 09:37:44 -07:00
Piotr Osiewicz
678bdddd7d
chore: Add crate licenses. (#4158)
- GPUI and all dependencies: Apache 2
- Everything else: AGPL

Here's a script that I've generated for it:
https://gist.github.com/osiewicz/6afdd6626e517da24a2092807e6f0b6e

Release Notes:
- N/A

---------

Co-authored-by: David <david@zed.dev>
2024-01-23 16:56:22 +01:00
Thorsten Ball
bf843e2131 Cache last used layer_id for StackingOrder
This optimizes rendering time by saving computation of the layer_id and
comparison when inserting it into the `BTreeMaps`.

Co-authored-by: Antonio <antonio@zed.dev>
2024-01-23 11:46:11 +01:00
Conrad Irwin
5a9f1e4eb7
fix local collab tests (#4209)
I was unable to run the collab tests locally because I would run out of
file descriptors.

From some digging it turned out that tokio allocates a new file
descriptor to do work on the CurrentThread using KQUEUE.

We create a new tokio Runtime with each database connection, and these
database connections were being retained by the Client, which is
retained by the Context.

Cleaning up our leaked contexts (and an unrelated retain cycle in the
UserStore) fixes the problem (though does make me
wonder if a different approach might be preferrable).

Release Notes:

- N/A
2024-01-22 23:17:23 -07:00
Conrad Irwin
d4e83e48bd Fix docs 2024-01-22 23:10:53 -07:00
Conrad Irwin
0b1b758f02 Fix leaking test contexts
I was unable to run the collab tests locally because I would run out of
file descriptors.

From some digging it turned out that tokio allocates a new file
descriptor to do work on the CurrentThread using KQUEUE.

We create a new tokio Runtime with each database connection, and these
database connections were being retained by the Client, which is
retained by the Context.

Cleaning up our leaked contexts fixes the problem (though does make me
wonder if a different approach might be preferrable).
2024-01-22 23:05:54 -07:00
Mikayla
a241a13d60
fix test 2024-01-22 19:42:25 -08:00
Mikayla
938b84c045
Finish documenting GPUI 2024-01-22 19:33:45 -08:00
Mikayla
eab2e21126
Document more styling functions 2024-01-22 19:31:31 -08:00
Mikayla
a99d5b87e8
WIP: text_system 2024-01-22 19:30:40 -08:00
Mikayla
0c3fb449f0
Document geometry 2024-01-22 19:30:40 -08:00
Mikayla
1902df9316
WIP: Start geometry crate 2024-01-22 19:30:40 -08:00
Mikayla
1f94463ce2
Switch Arc<Mutex<Keymap>> to Rc<RefCell<Keymap>>, a relic of the GPUI2 port.
Make gpui pass clippy
2024-01-22 19:30:38 -08:00
Kirill Bulatov
a75fa35a08 Fix the fonts panic
co-authored-by: Piotr <piotr@zed.dev>
2024-01-23 00:23:48 +02:00
Conrad Irwin
2445df8bdd Remove unused import? 2024-01-22 13:37:14 -07:00
Conrad Irwin
a1c4716eeb
Potential fix for #2422 (#4197)
- it seems like layer.drawable_size() is 0,0 in metal_renderer.rs:189 
- we set this in two places:
    - in response to a CALayerDelegate setFrameSize: event
- in response to a CALayerDelegate viewDidChangeBackingProperties:
event.
- it looks like if we don't set it in either of these cases we get a
different failure mode: the view is zoomed just wrong.
- That said, I can reproduce the screenshot if .scale_factor() returns
0.
- This might happen if [nativeWindow screen] is nil, which happens when
the window is off screen.
    - possible that zed started with offscreen window?
- I would expect that viewDidChangeBackingProperties would fire when
that changed.
    - potential fix: default to 2.0

Release Notes:

- Fixed Zed occasionally rendering blank on laungh
([#2422](https://github.com/zed-industries/community/issues/2422)).
2024-01-22 11:25:02 -07:00
Mikayla Maki
e896941981
Fix certain hovers being cut off (#4196)
Release Notes:

- Fixes a bug where the bottom of hover popovers would be cut off
([#2434](https://github.com/zed-industries/community/issues/2434)).
2024-01-22 10:19:39 -08:00
Conrad Irwin
72cb865108
jk (#4189)
Add support for mapping `jk` to escape in vim mode.

This changes the behaviour of the keymatches when there are pending
matches.

Before: Even if there was a pending match, any complete matches would be
triggered and the pending state lost.

After: If there is a pending match, any complete matches are delayed by
1s, or until more keys are typed.

Release Notes:

- Added support for mapping `jk` in vim mode
([#2378](https://github.com/zed-industries/community/issues/2378)),
([#176](https://github.com/zed-industries/community/issues/176))
2024-01-22 11:12:43 -07:00
Conrad Irwin
41a99c686b Potential fix for #2422 2024-01-22 11:10:15 -07:00
Mikayla
6419df82ee
Fix certain hovers being cut off 2024-01-22 09:49:07 -08:00
Conrad Irwin
c49477746e TYPO 2024-01-22 09:56:59 -07:00
Conrad Irwin
0903d29ab3 Improve logic for reused bindings, add docs. 2024-01-22 09:53:04 -07:00
Julia
3b3252b040 Rewrote and documented was_top_layer logic
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2024-01-22 11:50:47 -05:00
Julia
455d5eeb89 Preserve stacking order ID order when reusing cached view state
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2024-01-22 10:50:52 -05:00
Conrad Irwin
6c4d024237 TYPO 2024-01-22 08:40:21 -07:00
Conrad Irwin
c5d7c8e122 Fix cmd-k left 2024-01-22 08:38:20 -07:00
Julia
831769ce8c Ignore stacking order entry ids in was_top_layer 2024-01-22 10:16:59 -05:00
Julia
2c3d9805a4 Store a z-index id per-layer
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2024-01-22 10:16:59 -05:00
Conrad Irwin
7ec4f22202 de-dbg! 2024-01-22 08:14:30 -07:00
Antonio Scandurra
de64de22a3 Introduce a ZED_MEASUREMENTS env var and use it to measure frame time 2024-01-22 11:39:20 +01:00
Conrad Irwin
b9c7bafc80 Merge remote-tracking branch 'origin/main' into jk 2024-01-21 22:03:54 -07:00
Conrad Irwin
4143d3a36e Work on tests 2024-01-21 22:00:35 -07:00
Mikayla
b65cae5874
Moved Frame struct into element context, to be close to it's associated methods 2024-01-21 20:52:24 -08:00
Mikayla
c05edee2b5
Port the rest of the app 2024-01-21 20:26:33 -08:00
Mikayla
df4566fd1e
Refactor out element context from GPUI 2024-01-21 19:43:35 -08:00
Conrad Irwin
9d261cf859 Merge branch 'main' into jk 2024-01-21 20:36:18 -07:00
Conrad Irwin
8c541b4930 Comment out tests for nwo 2024-01-21 20:16:14 -07:00
Conrad Irwin
b06e2eb6af Update handling of 'pending' keys
Before this change if you had a matching binding and a pending key,
the matching binding happened unconditionally.

Now we will wait a second before triggering that binding to give you
time to complete the action.
2024-01-21 20:12:01 -07:00
Mikayla
2f9958621b
Do an initial pass on refactoring out ElementContext from WindowContext 2024-01-21 18:40:20 -08:00
Mikayla Maki
a8990baaac
Document more gpui (#4187)
Also add several `TODO!(docs)` comments to places that need more
feedback.

Release Notes:

- N/A
2024-01-21 15:10:04 -08:00
Mikayla
118a3461a7
Restore erronously removed APIs 2024-01-21 14:33:34 -08:00
Mikayla
660a391806
Fix typos, mark docs related todos in GPUI 2024-01-21 14:28:40 -08:00
Mikayla
aa57a4cfbc
Document / lockdown more of GPUI 2024-01-21 14:26:45 -08:00
Conrad Irwin
b8ed83a452 Refactor key dispatch to work in terms of bindings 2024-01-21 12:27:26 -07:00
Piotr Osiewicz
6c82380232 chore: Fix clippy::needless_borrow up to an editor 2024-01-21 15:03:24 +01:00
Thorsten Ball
29e74a648f
When searching in visual mode switch to normal mode (#4178)
This matches Neovim behaviour by setting the mode to `Normal` when using
search while in visual mode.

Release Notes:

- Fixed Vim mode not switching to normal mode from visual mode when
using search (`/`) while in visual mode.
2024-01-21 08:42:47 +01:00
Mikayla
476de329b3
Fix issues in element comment 2024-01-20 20:19:01 -08:00
Mikayla
2083fdcaf6
Fix compile issue 2024-01-20 20:15:43 -08:00
Mikayla
bf878b8257
Document the canvas and div 2024-01-20 20:15:23 -08:00
Mikayla
a44aae9e91
Finish documenting the action, asset, color, and element modules in GPUI
Remove SmallVec from the public API of GPUI
2024-01-20 20:15:23 -08:00
Conrad Irwin
3b84291343
Updates to chat after Hack#2 (#4175)
Release Notes:

- Channels: Improved font sizes in chat
- Channels: Added a link preview when hovering over links in chat
- Channels: Fixed rendering of newlines in chat messages
- Added a new setting "use_autoclose" (defaulting to true) that lets you
disable autoclose per language.
([#1420](https://github.com/zed-industries/community/issues/1420))
([#1903](https://github.com/zed-industries/community/issues/1903))
2024-01-20 20:03:37 -07:00
Mikayla
4184686e8d
Lock down test platform implementation 2024-01-20 15:03:36 -08:00
Mikayla
017661818d
Fix typo 2024-01-20 14:42:38 -08:00
Mikayla
9da6b8c7f6
Lock down mac os platform type visibility in the rest of GPUI
Add documentation to all platform types
2024-01-20 14:38:03 -08:00
Conrad Irwin
29ac1fd081 Merge remote-tracking branch 'origin/main' into chat-font-size 2024-01-20 14:51:53 -07:00
Thorsten Ball
87be105af7 When searching in visual mode switch to normal mode
This matches Neovim behaviour by setting the mode to `Normal` when using
search while in visual mode.

Co-authored-by: Conrad <conrad@zed.dev>
2024-01-20 16:33:07 +01:00
Mikayla
33105486aa
Make platform input handler private
Automatically record the context on non-view input handlers
Simplify the async window context update() method
2024-01-20 06:56:19 -08:00
Conrad Irwin
23d991962a Link previews in chat 2024-01-19 16:59:17 -07:00
Conrad Irwin
cb84043400 Merge branch 'main' into fix-notification-positioning 2024-01-19 12:55:52 -07:00
Conrad Irwin
00e46fdde0 Fix positioning of windows on secondary displays
CGDisplayBounds returns data in "global display coordinates" (which are
the same as Zed's coordinates), different from the NS APIs which use
"screen coordinates" (which have the Y axis inverted)

Also remove some transmutes while we're at it
2024-01-19 12:51:59 -07:00
Marshall Bowers
1cc7f66f86
Fix documentation labels obscuring other content in completion menu (#4167)
This PF fixes an issue where the documentation labels in the completion
menu could end up completing obscuring the primary content.

#### Before
<img width="691" alt="Screenshot 2024-01-19 at 1 42 19 PM"
src="https://github.com/zed-industries/zed/assets/1486634/187f2978-08be-4f5e-ba93-91ed09cd6e87">

#### After

<img width="704" alt="Screenshot 2024-01-19 at 1 39 45 PM"
src="https://github.com/zed-industries/zed/assets/1486634/e5929c04-bace-4336-b878-4ada5660d235">

Since this involved changes to the `ListItem`, I also made sure to test
the other problematic case that was fixed in #3845 to make sure we
didn't regress there:

<img width="665" alt="Screenshot 2024-01-19 at 1 39 11 PM"
src="https://github.com/zed-industries/zed/assets/1486634/14b72d44-b6a6-4aef-a708-37fb60b8875a">

I also tried to capture these cases in the `ListItem` stories to make it
easier to test all of them at once:

<img width="1141" alt="Screenshot 2024-01-19 at 1 40 03 PM"
src="https://github.com/zed-industries/zed/assets/1486634/333886ff-e394-4cba-89db-98352481c7f6">

Release Notes:

- Fixed an issue where documentation labels could obscure other content
in the editor completion menu
([#2419](https://github.com/zed-industries/community/issues/2419)).
2024-01-19 14:01:09 -05:00
Conrad Irwin
2166f071b3
Fix panic in window open (#4148)
Fix a panic caused by toggleFullScreen on one window untoggling
full-screen on
another.

I managed to reproduce this only once, which makes me sad, but this
change
should fix it regardless.

https://zed-industries.slack.com/archives/C04S6T1T7TQ/p1705631681238979

Release Notes:

- Fixed an occasional panic when opening a new fullscreen window.
2024-01-19 11:08:06 -07:00
Marshall Bowers
01f06f96a1
Update tenses of doc comment summary lines (#4161)
This PR updates the tenses used by the summary line of doc comments to
match the [Rust API documentation
conventions](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#summary-sentence).

Specifically:

> The summary line should be written in third person singular present
indicative form. Basically, this means write ‘Returns’ instead of
‘Return’.

I'm sure there are plenty occurrences that I missed.

Release Notes:

- N/A
2024-01-19 11:18:50 -05:00
Antonio Scandurra
9446e573e9 Reuse layout for view's element when it wasn't cached 2024-01-19 10:26:39 +01:00
Conrad Irwin
d76bd100f5
Show cursors for remote participants (#4082)
This PR enables cursors for remote participants.

They are shown for 2 seconds when you focus a buffer, and then on hover.

Release Notes:

- Added usernames next to remote cursors
2024-01-18 20:58:09 -07:00
Conrad Irwin
87d60beda7 Fix a double borrow error in window.open
It seems that sometimes calling toggleFullScreen will cause the
display_layer callback of a different window to fire.
2024-01-18 20:55:50 -07:00
Marshall Bowers
decf320a74
Rename overflow_hidden_{x,y} to overflow_{x,y}_hidden (#4146)
This PR renames the `overflow_hidden_x` and `overflow_hidden_y` methods
to `overflow_x_hidden` and `overflow_y_hidden`, respectively.

This provides consistency with our `overflow_x_scroll` /
`overflow_y_scroll` methods, as well as better matches Tailwind's
naming.

Release Notes:

- N/A
2024-01-18 22:10:41 -05:00
Mikayla Maki
bac2e59eac
Fix popin for project panel by pre-resolving keybindings in the project panel (#4141)
Also, factors out the fluent building APIs from IntoElement into their
own traits.

Also makes the project panel context menu initialization fluent:

<img width="1328" alt="Screenshot 2024-01-18 at 3 33 45 PM"
src="https://github.com/zed-industries/zed/assets/2280405/3468b6f2-07f0-48cf-bec1-ac0379333209">

Release Notes:

- Fixed pop in when right clicking on the project panel.
2024-01-18 16:16:50 -08:00
Mikayla Maki
20b58fea35
Merge branch 'main' into fix-popin-for-project-panel 2024-01-18 15:55:35 -08:00
Marshall Bowers
3542b99c9d
Tweak the description of the gpui crate (#4142)
This PR tweaks the description of the `gpui` crate, since it's now the
only version.

There can only be one!

Release Notes:

- N/A
2024-01-18 18:52:16 -05:00
Mikayla
903176d8ff
Pull out fluent builder helpers into re-usable trait 2024-01-18 15:31:31 -08:00
Max Brunsfeld
7860372beb
gpui: Always recompute layout on cache miss. (#4131)
I'm not yet sure whether this is 100% correct, but it seems to alleviate
the following issue:
`When opening a dock, the panel doesn't appear right away. An empty dock
is briefly visible.`
Release Notes:

- Fixed panel layout being incorrect for a brief time after opening
(fixes https://github.com/zed-industries/community/issues/2415)
2024-01-18 14:44:35 -08:00
Conrad Irwin
bfee008bb2 Merge branch 'main' into cursors 2024-01-18 14:03:27 -07:00
Conrad Irwin
6c2da0d25b Revert "Store a z-index id per-layer (#4128)"
This reverts commit 28a2337218, reversing
changes made to e992f84735.
2024-01-18 13:28:23 -07:00
Conrad Irwin
81baefb460
Fix right click handler for tabs (#4130)
Also, some fun test helpers

Co-Authored-By: Mikayla <mikayla@zed.dev>

You can now use .debug_selector() to make it possible for tests to find
a given element,
and .debug_bounds() to find the coordinates of where it was painted.


Release Notes:

- (Added|Fixed|Improved) ...
([#<public_issue_number_if_exists>](https://github.com/zed-industries/community/issues/<public_issue_number_if_exists>)).
2024-01-18 13:07:25 -07:00
Piotr Osiewicz
4408d45f7a gpui: Always recompute layout on cache miss. 2024-01-18 20:55:41 +01:00
Conrad Irwin
920eced1d5 Fix right click handler for tabs
Also, some fun test helpers

Co-Authored-By: Mikayla <mikayla@zed.dev>
2024-01-18 12:10:38 -07:00
Julia
bc2302f723 Store a z-index id per-layer
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2024-01-18 13:24:25 -05:00
Thorsten Ball
b30efc9e81 Fix missing icons: set svg_renderer when assets are updated
Co-authored-by: Mikayla <mikayla@zed.dev>
2024-01-18 16:26:54 +01:00
Nathan Sobo
9e37232a13 Merge remote-tracking branch 'origin/main' into ownership-post 2024-01-18 07:01:54 -07:00
Nathan Sobo
f9165938b0 More adjustments for blog post 2024-01-18 07:01:46 -07:00
Piotr Osiewicz
0a0921f88b gpui: Bring back family and style names in font name suggestions 2024-01-18 12:10:17 +01:00
Antonio Scandurra
559461923f Remove unused PlatformAtlas::clear method 2024-01-18 10:40:15 +01:00
Nathan Sobo
bef1b83265 Add ownership post example 2024-01-17 21:19:28 -07:00
Nathan Sobo
1d3ca8eb5d Adjust APIs for simpler examples in blog post 2024-01-17 21:19:28 -07:00
Mikayla Maki
aa7351041d
Add typo detection to CI (#4107)
Adding the typos crate to our CI will take some doing, as we have
several tests which rely on typos in various ways (e.g. checking state
as the user types), but I thought I'd take a first stab at fixing what
it finds.

Release Notes:

- N/A
2024-01-17 17:13:47 -08:00
Mikayla
6ea23d0704
Fix canary 2024-01-17 17:03:17 -08:00
Piotr Osiewicz
ec2b299ecb
settings: Suggest fonts bundled in Zed (#4102)
Fixes an issue where Zed Sans is not being suggested as a font.

Release Notes:
- N/A
2024-01-18 00:54:07 +01:00
Mikayla
e3e3ef528e
Add typos ci 2024-01-17 15:33:14 -08:00
Mikayla
e6ca92ffa4
Fix a few more typos 2024-01-17 14:58:58 -08:00
Mikayla Maki
0711476fd5
Merge branch 'main' into fix-typos 2024-01-17 14:36:03 -08:00
Mikayla Maki
75f8748509
Document party 2 (#4106)
@mikayla-maki and @nathansobo's contributions

Release Notes:

- N/A
2024-01-17 14:33:52 -08:00
Mikayla
57400e9687
Fix typos detected by crate-ci/typos 2024-01-17 14:31:21 -08:00
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
Mikayla
9eecda2dae
Update method name and partially document platform crate
co-authored-by: Nathan <nathan@zed.dev>
2024-01-17 14:07:57 -08:00
Mikayla
7a299e966a
Document view crate
co-authored-by: Nathan <nathan@zed.dev>
2024-01-17 14:07:55 -08:00
Mikayla
d67e461325
document app module in gpui 🎉
co-authored-by: Nathan <nathan@zed.dev>
2024-01-17 14:07:41 -08:00
Mikayla
6db18e8972
Drop scroll events if there's been a reset
co-authored-by: Nathan <nathan@zed.dev>
co-authored-by: Conrad <conrad@zed.dev>
2024-01-17 13:57:16 -08:00
Julia
2fbf42d7df
Z index shenanigans (#4089)
Release Notes:

- Fixed a bug allowing certain UI elements to render incorrectly when
overlapping.
2024-01-17 09:48:08 -05:00
Thorsten Ball
5b0b9ff582 Submit bigger primitive batches when rendering
Before this change we wouldn't submit all possible primitives of the
same kind that are less-than the max order.

Result was that we would submit, say, 10 paths each in a separate batch
instead of actually batching them.

This was overly strict because even if the order of two different
primitives was the same, we could have still batched the 1st primitive
kind, if its implicit ordering was less than 2nd kind.

Example: say we have the following primitives and these orders

  5x paths, order 3
  2x sprites, order 3

Previously, we would submit 1 path, 1 path, 1 path, 1 path, 1 path, then
the sprites.

With this changes, we batch the 5 paths into one batch.

Co-authored-by: Antonio <antonio@zed.dev>
2024-01-17 13:50:55 +01:00
Antonio Scandurra
9c33790809 Check if we exhausted the instance buffer prior to copying underlines
This fixes another potential segfault.
2024-01-17 09:50:55 +01:00
Antonio Scandurra
97bd3e1fde Fix segfault caused by wrong size of path sprites bytes length
Previously, we were using `size_of` but passing the wrong type in
(MonochromeSprite instead of PathSprite). This caused us to read outside
of the `sprites` smallvec and triggered the segfault.
2024-01-17 09:45:46 +01:00
Mikayla
80852c3e18
Add documentation to the new test 2024-01-16 22:34:15 -08:00
Mikayla
a99ee5e599
Fix test failures 2024-01-16 22:30:44 -08:00
Mikayla
cae35d3334
Fix draw helper, add helper traits for selecting groupings of input events 2024-01-16 22:19:55 -08:00
Conrad Irwin
0ca9f286c6 Show cursors for remote participants 2024-01-16 21:54:49 -07:00
Mikayla
db433586aa
Add some small test code for tracking down this list bug 2024-01-16 16:52:55 -08:00
Conrad Irwin
391a61cdc2
Play guess who's to blame (#4078)
We're occasionally seeing a crash in MetalRenderer::draw.

Looking at the backtrace, it seems almost certainly to be happening in
the call to `ptr::copy_nonoverlapping` on line 604 (see `#Don't Panic!`
channel notes)

As we already have added bounds checking to the destination, it seems
most
likely (however improbable) that somehow we're getting an invalid Ptr
and
length from the SmallVec.

To try and make progress on this, let's try a Vec for a bit lest there
is a subtle issue in SmallVec (though I couldn't spot one).


Release Notes:

- (maybe) Fixes SEGFAULT in MetalRenderer::draw
2024-01-16 16:10:36 -07:00
Conrad Irwin
cce3cf145c Play guess who's to blame 2024-01-16 15:39:37 -07:00
Piotr Osiewicz
f011953484 Rename all_font_families to all_font_names 2024-01-16 20:32:21 +01:00
Julia
60b79ef2ea Prevent content mask breaks from having the same z-index
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2024-01-16 11:23:28 -05:00
Julia
4f25df6ce2 Prevent div background/content/border from interleaving at same z-index
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2024-01-16 11:22:14 -05:00
Julia
4e0c8dcea9 Revert "Use taffy to retrieve the parent for a given layout node"
This reverts commit 5904bcf1c2.

Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2024-01-16 10:44:24 -05:00
Thorsten Ball
f938bae0a2 Use NSScreen to fetch primary display
According to Chromium source, `NSScreen::screens` should always get us
one display.

We made this change because we ran into panics caused by the previous
`unwrap()` when `CGGetActiveDisplayList` might return an empty list.
2024-01-16 14:23:10 +01:00
Thorsten Ball
03bfe3ef80 Call CGGetActiveDisplayList once to avoid panic
Previously we called CGGetActiveDisplayList twice: once to get the
number of displays and then to get the displays.

We saw a panic due to no displays being returned here. As a first
attempt to fix the panic, we're reducing the amount of calls to
CGGetActiveDisplayList and just do one with the trade-off being that we
pre-allocate 32 pointers in a Vec.
2024-01-16 12:01:54 +01:00
Max Brunsfeld
deac172e39
Restore re-rendering of editors on buffer font size changes (#4064)
Now that views are cached, we need to explicitly `.notify()` text
editors when the buffer font size changes.

* [x] Notify editors when settings change, or adjusting buffer font size
* [x] Figure out why non-focused editors still do not re-render when
adjusting buffer font size
* [x] Reset buffer font size adjustment when the size is updated in the
user's settings
2024-01-15 17:13:13 -08:00
Max Brunsfeld
1e755aa00f Notify global observers when removing a global 2024-01-15 17:02:20 -08:00
Max Brunsfeld
8f1633e798 Iterate from leaf to root when marking views dirty in notify 2024-01-15 16:49:06 -08:00
Conrad Irwin
f0ed80cd8e Fix fallback font
As this is used if you mis-spell "buffer_font_family", it should be
monospace.

Also treat "Zed Mono" and "Zed Sans" as valid fonts
2024-01-15 14:32:48 -07:00
Antonio Scandurra
69bbcba99a Preserve tooltips requested by cached views
Co-Authored-By: Nathan <nathan@zed.dev>
Co-Authored-By: Max <max@zed.dev>
2024-01-15 19:19:27 +01:00
Antonio Scandurra
0ff5603dc9 Rebuild shader header when cbindgen sources have changed
Co-Authored-By: Thorsten <thorsten@zed.dev>
2024-01-15 16:23:22 +01:00
Piotr Osiewicz
e52a2298cc
gpui: Pin to font-kit with improved OTC parsing performance. (#4047)
Details are in https://github.com/zed-industries/font-kit/pull/1; We're
not doing anything too fancy, really. Still, you should mostly see font
loading times drop significantly for font collections
Release Notes:
- Improved loading performance of large font collections (e.g. Iosevka).
Fixes https://github.com/zed-industries/community/issues/1745,
https://github.com/zed-industries/community/issues/246


https://github.com/zed-industries/zed/assets/24362066/f70edbad-ded6-4c12-9c6d-7a487f330a1b
2024-01-15 15:46:18 +01:00
Antonio Scandurra
05d05b051b Pop node from dispatch tree during cx.paint_view
Co-Authored-By: Thorsten <thorsten@zed.dev>
2024-01-15 11:46:46 +01:00
Antonio Scandurra
4ff514ca7e Merge remote-tracking branch 'origin/main' into cache
# Conflicts:
#	crates/gpui/src/elements/div.rs
2024-01-15 11:37:46 +01:00
Conrad Irwin
29ce109211
chat panel ++ (#4044)
- Update chat panel with current channel
- Open chat panel for guests
- Open chat when joining a channel with guests
- Some tweaks for chat panels
- Don't lose focus on default panel state
- Make chat prettier (to my eyes at least)
- Fix multiple mentions in one message
- Show a border when scrolled in chat
- Fix re-docking chat panel
- Move settings subscription to dock

[[PR Description]]

Release Notes:

- Opens chat by default when joining a public channel
- Improves chat panel UI
2024-01-14 13:54:10 -07:00
Conrad Irwin
e90ddba2c3 Default to Zed Sans for UI 2024-01-13 22:38:22 -07:00
Conrad Irwin
818cbb2415 Show a border when scrolled in chat 2024-01-13 22:19:21 -07:00
Conrad Irwin
f6ef07e716 Make chat prettier (to my eyes at least) 2024-01-13 21:37:13 -07:00
Mikayla
5897b18cfd
remove more commented code 2024-01-12 20:10:40 -08:00
Mikayla
3a836b8026
Remove some comments 2024-01-12 20:10:40 -08:00
Nathan Sobo
d2c436dcdc
fix bounds checks (#4038)
Ensure we `panic()` instead of crash on graphics memory buffer overflow

Also bump the buffer size to 32Mb from 8Mb to make this rarer (but still
possible)

Release Notes: Fixes some crahes due to lack of graphics buffer spacae
2024-01-12 15:28:19 -08:00
Julia
cdc227b32f Still paint group hover handler for invisible divs
Fixes bug where tab close icon show on hover is inconsistent
2024-01-12 17:44:15 -05:00
Conrad Irwin
aa5c6a8aa3 Update graphics memory assert to be more helpful 2024-01-12 14:35:50 -07:00
Mikayla
324d1d119b
Add some context to assert 2024-01-12 12:40:37 -08:00
Conrad Irwin
551fd9ba7e Boop 2024-01-12 12:40:09 -07:00
Antonio Scandurra
817b641c17 Ensure editor elements invalidate their parent views on notify
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Conrad Irwin <conrad@zed.dev>
2024-01-12 17:36:11 +01:00
Antonio Scandurra
a32ad3f907 Fix editor tests 2024-01-12 14:50:42 +01:00
Antonio Scandurra
94293b3bf9 Merge remote-tracking branch 'origin/main' into cache
# Conflicts:
#	crates/gpui/src/window.rs
2024-01-12 14:31:13 +01:00
Piotr Osiewicz
8d294211db settings.json: Suggest font names for buffer_font_family 2024-01-11 23:23:10 +01:00
Piotr Osiewicz
a1049546a2 gpui: Validate font contents at load time.
During layout of EditorElement we use 'm' character from current font to calculate sizes, panicking with fonts that do not have that character (e.g. Arabic fonts). It's not really EditorElement's fault, as it assumes that the font it's dealing with is gonna have that character available.
To prevent a crash, I added validation while loading a family that a given font contains the glyphs we're gonna use down the line.
2024-01-11 23:23:10 +01:00
Conrad Irwin
a8b8be47e0 Don't hold platform lock while calling user callbacks
Inspired by a bug where using Edit -> Copy from the menu created a
deadlock.
2024-01-11 13:52:50 -07:00
Conrad Irwin
4d66ade332
Fix multi-key shortcuts (#4025)
An old fix was ported over from gpui1, and the two fixes could not exist
side-by-side. Delete this code and let the keymap handle it

Release Notes:

- (Added|Fixed|Improved) ...
([#<public_issue_number_if_exists>](https://github.com/zed-industries/community/issues/<public_issue_number_if_exists>)).
2024-01-11 11:36:51 -07:00
Conrad Irwin
51cc6b1e1c
Guard against infinite loop in focus handling (#4023)
Release Notes:

- Fix an infinite loop in focus handling
2024-01-11 11:26:37 -07:00
Conrad Irwin
23fe720ca6 Fix multi-key shortcuts
An old fix was ported over from gpui1, and the two fixes could not exist
side-by-side. Delete this code and let the keymap handle it
2024-01-11 11:24:55 -07:00
Piotr Osiewicz
a98d048905
gpui: Make TextSystem::line_wrapper non-fallible. (#4022)
Editors WrapMap could become desynchronised if user had an invalid font
specified in their config. Compared to Zed1, WrapMap ignored the
resolution failure instead of panicking. Now, if there's an invalid font
in the user config, we just fall back to an arbitrary default.


Release Notes:
- Fixed the editor panic in presence of invalid font name in the config
(fixes https://github.com/zed-industries/community/issues/2397)

---------

Co-authored-by: Conrad <conrad@zed.dev>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2024-01-11 18:52:00 +01:00
Conrad Irwin
06493471aa Guard against infinite loop in focus handling 2024-01-11 10:38:08 -07:00
Antonio Scandurra
11b433dc1c Move back to sorting entries in the depth map as we insert them 2024-01-11 18:24:07 +01:00
Antonio Scandurra
101cedb5f7 💄 2024-01-11 16:59:33 +01:00
Antonio Scandurra
cbbba41748 Reuse line layouts when reusing view 2024-01-11 16:57:06 +01:00
Antonio Scandurra
18eaefd0ed Reuse cursor style when reusing a view tree 2024-01-11 15:03:34 +01:00
Antonio Scandurra
50ccdf5c16 Reuse input handler when reusing a view tree 2024-01-11 13:22:59 +01:00
Antonio Scandurra
d088ace404 Explicitly push a node in the dispatch tree when painting a new view 2024-01-11 12:48:05 +01:00
Antonio Scandurra
142a8b68c8 Avoid casting view ids to u32
Also, it looks like using a u64 directly doesn't work well with Metal
shaders, so we unpack the u64 into two u32s.
2024-01-11 12:28:48 +01:00
Mikayla
83163a0031
Reverse context arrays in child predicate test 2024-01-10 19:54:39 -08:00
Mikayla
38396d4281
Add remaining tests
co-authored-by: Conrad <conrad@zed.dev>
2024-01-10 19:39:43 -08:00
Mikayla
a5ca58354d
Fix first few asserts 2024-01-10 18:26:01 -08:00
Mikayla
1932a298cb
Add back ime_key 2024-01-10 16:29:00 -08:00
Antonio Scandurra
a4ef1bc096 Rename reuse_geometry to reuse_view 2024-01-10 23:06:10 +01:00
Antonio Scandurra
1c260e6dfd Merge remote-tracking branch 'origin/main' into cache
# Conflicts:
#	crates/copilot/src/sign_in.rs
#	crates/gpui/src/window.rs
#	crates/workspace/src/pane_group.rs
2024-01-10 22:58:52 +01:00
Mikayla
f71a0cddb8
Remove last todos 2024-01-10 12:13:12 -08:00
Mikayla
4bcac68c8c
Restore GPUI test 2024-01-10 11:43:52 -08:00
Mikayla
7ef88397c9
Fix seg fault when using the WindowContext::on_window_should_close() API 2024-01-10 11:26:11 -08:00
Mikayla
c98d7adf83
Audit all TODOs in Zed and mark port related todos 2024-01-10 11:26:11 -08:00
Max Brunsfeld
69a93edabd Ensure ArenaRef pointers are aligned to their contained type
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
2024-01-10 10:36:08 -08:00
Conrad Irwin
5dff458014
Ensure focus_in and focus_out fire on window activation (#3993)
Also:
- Rename cx.on_blur to cx.on_focus_lost
- Fix a bug where notify calls in focus handlers were ignored
- Fix a bug where vim would get stuck in the wrong mode when switching
  windows

Release Notes:

- (preview only) vim: fix switching between multiple windows
2024-01-10 10:00:07 -07:00
Antonio Scandurra
2923b71f83 Replace WindowContext::notify with WindowContext::refresh 2024-01-10 17:27:02 +01:00
Marshall Bowers
aff119b80a
Fix possessive "its" in docs and comments (#3998)
This PR fixes a number of places where we were incorrectly using "it's"
where we needed to use the possessive "its".

Release Notes:

- N/A
2024-01-10 10:09:48 -05:00
Antonio Scandurra
d0c101cb6e Reuse depth map entries and retain element states for cached trees 2024-01-10 15:00:40 +01:00
Kirill Bulatov
c197ea49ca Simplify uniform list scrolling logic 2024-01-10 13:45:50 +02:00
Kirill Bulatov
f57ff1c660 Make the scroll position updated as soon as possible to the correct deferred value
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
2024-01-10 12:16:06 +02:00
Antonio Scandurra
881c532256 Insert primitives associated with views from a previous scene 2024-01-10 10:50:16 +01:00
Kirill Bulatov
927e0db750 An attempt to defer scrolls during empty initial state 2024-01-10 11:26:23 +02:00
Kirill Bulatov
6809b92e34 Disable synthetic drag on drag and drop
Otherwise, conflicting MouseMove events are generated and page regions start to flicker.
2024-01-10 11:18:45 +02:00
Conrad Irwin
5d3f5611e5
guest promotion (#3969)
Release Notes:

- Adds the ability to promote read-only guests to read-write
participants in calls
2024-01-09 22:21:13 -07:00
Conrad Irwin
2ca462722c Fix some tests (mostly more run_until_parked's...) 2024-01-09 22:14:11 -07:00
Conrad Irwin
72c022f413 Ensure focus-sensitive tests have active windows 2024-01-09 21:38:06 -07:00
Conrad Irwin
1bf33b4b61 Ensure focus_in and focus_out fire on window activation
Also:
- Rename cx.on_blur to cx.on_focus_lost
- Fix a bug where notify calls in focus handlers were ignored
- Fix a bug where vim would get stuck in the wrong mode when switching
  windows
2024-01-09 20:55:00 -07:00
Mikayla Maki
45baad2825
Remove or fix stale todos (#3990)
The software equivalent of dusting

Release Notes:

-
2024-01-09 18:37:35 -08:00
Mikayla
e786e22121
And a few more todos 2024-01-09 16:41:17 -08:00