Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Find a file
tims ca9cee85e1
linux: Fix non-maximized Zed windows growing larger across sessions (#22301)
Closes #17870

Context:

On Linux, when creating a new window, bounds are either pulled from
existing workspace data (serialized in an SQLite DB) or fall back to
some default constants if no data exists.

These bounds include the full dimensions of the window (width and
height), which already account for insets. However, properties like
`inset` (Wayland) or `last_insets` (X11) exist only at the platform
level and are not part of the window bounds themselves.

During rendering, we call `set_client_inset`, which updates the inset
values and also adjusts the window bounds, increasing their dimensions.
In Zed's case, the inset is 10px, which adds 20px to both the width and
height (10px from each side).

Problem:

When quitting, the full window bounds (which already account for inset)
are saved to the DB. On reopening, these saved bounds are used to create
the window. `set_client_inset` runs again and inflates the dimensions
even more.

Solution:

Store window bounds *without* the inset-inflated dimensions. On the next
session, `set_client_inset` will take care of applying the inset,
resulting window dimensions matching the previous session. This fix is
in the PR.

Alternative Solution:

Another option is to save the inset explicitly in the DB and apply it
during window creation. But this means storing more data, and the inset
would need to be platform-agnostic, which adds complexity. Doesn’t seem
worth it for no real gain.

X11 Before:
```sh
saving window bounds with width: 1136, height: 784
tims@lemon ~/w/zed (fix-window-growing-larger)> cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.37s
     Running `target/debug/zed`
saving window bounds with width: 1156, height: 804   <---- +20px
tims@lemon ~/w/zed (fix-window-growing-larger)> cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.35s
     Running `target/debug/zed`
saving window bounds with width: 1176, height: 824  <---- +20px
tims@lemon ~/w/zed (fix-window-growing-larger)> cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.36s
     Running `target/debug/zed`
saving window bounds with width: 1196, height: 844  <---- +20px
```

X11 After:
```sh
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.35s
     Running `target/debug/zed`
saving window bounds with width: 1116, height: 764
tims@lemon ~/w/zed (fix-window-growing-larger)> cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.35s
     Running `target/debug/zed`
saving window bounds with width: 1116, height: 764     <---- same
tims@lemon ~/w/zed (fix-window-growing-larger)> cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.35s
     Running `target/debug/zed`
saving window bounds with width: 1116, height: 764   <---- same
```

On Wayland, saving occurs only when you actually resize the window (on
X11, saving happens both on init and while dragging the window). To
trigger saving, I manually resized the window by ~1px to make it print.

Wayland Before:
```sh
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1m 36s
     Running `target/debug/zed`
saving window bounds with width: 945, height: 577
tims@orange ~/zed (fix-window-growing-larger)> cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.77s
     Running `target/debug/zed`
saving window bounds with width: 966, height: 597    <--- +20px on both  (1px increase in width is me resizing)
tims@orange ~/zed (fix-window-growing-larger)> cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.87s
     Running `target/debug/zed`
saving window bounds with width: 987, height: 618    <--- +20px on both  (1px increase in width and height is me resizing)
tims@orange ~/zed (fix-window-growing-larger)> cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.89s
     Running `target/debug/zed`
saving window bounds with width: 1006, height: 638   <--- +20px on both  (1px decrease in width is me resizing)
```

Wayland After:
```sh
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.82s
     Running `target/debug/zed`
saving window bounds with width: 925, height: 558
tims@orange ~/zed (fix-window-growing-larger)> cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.84s
     Running `target/debug/zed`
saving window bounds with width: 925, height: 557     <--- same (1px decrease in height is me resizing)
saving window bounds with width: 925, height: 558
```

Release Notes:

- Fix non-maximized zed windows growing larger across sessions on Linux

---------

Co-authored-by: mgsloan@gmail.com <michael@zed.dev>
2024-12-20 22:23:25 +00:00
.cargo Use LiveKit's Rust SDK on Linux while continue using Swift SDK on Mac (#21550) 2024-12-05 15:06:17 -08:00
.cloudflare docs: Document context servers (#21170) 2024-11-25 11:05:14 -05:00
.config tests: Test 'db' package sequentially (#2654) 2023-06-28 15:00:43 +02:00
.github Add a CI check for todo! and FIXME comments (#21950) 2024-12-20 08:38:50 +00:00
.zed ci: Move collab to Dockerfile-collab (#18515) 2024-09-30 16:14:26 -04:00
assets Hide chat panel button when not in a call (#22200) 2024-12-19 19:32:45 +00:00
crates linux: Fix non-maximized Zed windows growing larger across sessions (#22301) 2024-12-20 22:23:25 +00:00
docs Add a CI check for todo! and FIXME comments (#21950) 2024-12-20 08:38:50 +00:00
extensions Add a CI check for todo! and FIXME comments (#21950) 2024-12-20 08:38:50 +00:00
legal Stop sending data to Clickhouse (#21763) 2024-12-10 08:47:29 -07:00
nix nix: Return to building with crane (#21292) 2024-11-29 10:09:33 +01:00
script Improve script/bump-zed-minor-version (#22199) 2024-12-20 21:02:57 +00:00
tooling/xtask chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
.git-blame-ignore-revs More ignorable commits (#14596) 2024-07-16 17:09:50 -04:00
.gitattributes Prevent GitHub from displaying comments within JSON files as errors (#7043) 2024-01-29 23:11:25 -05:00
.gitignore nix: Return to building with crane (#21292) 2024-11-29 10:09:33 +01:00
.mailmap Update .mailmap (#20729) 2024-11-15 11:05:41 -05:00
Cargo.lock Reapply completion docs prefetch (#22306) 2024-12-20 22:16:07 +00:00
Cargo.toml Use stable Alacritty crate version (#22304) 2024-12-20 21:40:22 +00:00
clippy.toml chore: Fix some violations of 'needless_pass_by_ref_mut' lint (#18795) 2024-10-07 01:29:58 +02:00
CODE_OF_CONDUCT.md Remove community content from docs and point to zed.dev (#19895) 2024-10-29 09:44:58 -04:00
compose.yml Add Postgrest to Docker Compose (#16498) 2024-08-19 20:50:45 -04:00
CONTRIBUTING.md Remove community content from docs and point to zed.dev (#19895) 2024-10-29 09:44:58 -04:00
Cross.toml Add remote server cross compilation (#19136) 2024-10-12 23:23:56 -07:00
debug.plist WIP 2023-12-14 09:25:14 -07:00
default.nix Add zed-editor package and overlay to flake (#16783) 2024-08-26 11:10:34 -04:00
docker-compose.sql collab: Setup database for LLM service (#15882) 2024-08-06 17:18:08 -04:00
Dockerfile-collab collab: Remove dependency on X11 (#19079) 2024-10-11 13:28:34 -04:00
Dockerfile-collab.dockerignore ci: Move collab to Dockerfile-collab (#18515) 2024-09-30 16:14:26 -04:00
Dockerfile-cross Add remote server cross compilation (#19136) 2024-10-12 23:23:56 -07:00
Dockerfile-cross.dockerignore Add remote server cross compilation (#19136) 2024-10-12 23:23:56 -07:00
Dockerfile-distros Support More Linux (#18480) 2024-09-30 17:46:21 -04:00
Dockerfile-distros.dockerignore Support More Linux (#18480) 2024-09-30 17:46:21 -04:00
flake.lock nix: Return to building with crane (#21292) 2024-11-29 10:09:33 +01:00
flake.nix nix: Return to building with crane (#21292) 2024-11-29 10:09:33 +01:00
LICENSE-AGPL chore: Add crate licenses. (#4158) 2024-01-23 16:56:22 +01:00
LICENSE-APACHE chore: Add crate licenses. (#4158) 2024-01-23 16:56:22 +01:00
LICENSE-GPL Licenses: change license fields in Cargo.toml to AGPL-3.0-or-later. (#5535) 2024-01-27 13:51:16 +01:00
livekit.yaml Add LiveKit server to Docker Compose (#7907) 2024-02-16 10:49:48 -05:00
Procfile Refactor: Restructure collab main function to prepare for new subcommand: serve llm (#15824) 2024-08-05 12:07:38 -07:00
Procfile.postgrest Fix llm queries (#16006) 2024-08-08 17:21:38 -07:00
README.md Format READMEs (#17454) 2024-09-05 15:39:16 -04:00
renovate.json Migrate Renovate config (#20741) 2024-11-15 14:37:39 -05:00
rust-toolchain.toml chore: Bump Rust to 1.81 (#17440) 2024-09-06 00:40:44 +02:00
shell.nix Add zed-editor package and overlay to flake (#16783) 2024-08-26 11:10:34 -04:00
typos.toml Stop sending data to Clickhouse (#21763) 2024-12-10 08:47:29 -07:00

Zed

CI

Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.


Installation

Packaging status

On macOS and Linux you can download Zed directly or install Zed via your local package manager.

Other platforms are not yet available:

Developing Zed

Contributing

See CONTRIBUTING.md for ways you can contribute to Zed.

Also... we're hiring! Check out our jobs page for open roles.

Licensing

License information for third party dependencies must be correctly provided for CI to pass.

We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:

  • Is it showing a no license specified error for a crate you've created? If so, add publish = false under [package] in your crate's Cargo.toml.
  • Is the error failed to satisfy license requirements for a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to the accepted array in script/licenses/zed-licenses.toml.
  • Is cargo-about unable to find the license for a dependency? If so, add a clarification field at the end of script/licenses/zed-licenses.toml, as specified in the cargo-about book.