Fixes #51456 ## Problem When opening a recent project with an unsaved scratch buffer (untitled file), the project switch silently fails. The log shows: ``` failed to save contents of buffer Caused by: FOREIGN KEY constraint failed ``` ## Root Cause When a user creates a new file from the welcome screen and edits it without saving, the buffer is dirty but has no file path. When opening a recent project, `prepare_to_close` calls `save_all_internal(SaveIntent::Close)`, which tries to serialize dirty items to the database for hot-exit functionality. The serialization fails with a FOREIGN KEY constraint error because workspace serialization is throttled - the workspace row may not exist in the database yet when the editor tries to INSERT into the editors table referencing that workspace_id. The previous code used `try_join_all` on all serialize tasks, so a single serialization failure would abort the entire close flow, preventing the project switch. ## Fix Replace `try_join_all` with individual task awaiting. If a serialize task fails, the item is moved back to the `remaining_dirty_items` list so the user gets a proper save/discard prompt instead of the action silently failing. This is a minimal change (7 insertions, 2 deletions) that: - Handles the FOREIGN KEY error gracefully - Preserves the save/discard prompt UX for items that fail serialization - Logs the serialization error for debugging via `.log_err()` - Does not change behavior for items that serialize successfully ## Test Plan - [ ] Open Zed with no active workspace - [ ] Create a new file from the welcome screen - [ ] Edit the buffer to make it dirty (do not save) - [ ] Open a recent project via `projects: open recent` - [ ] Verify the project opens (previously it silently failed) - [ ] Verify a save/discard prompt appears for the dirty scratch buffer Release Notes: - Fixed opening a recent project silently failing when an unsaved scratch buffer is present (#51456). --- This PR was written with the assistance of AI (Claude). --------- Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com> |
||
|---|---|---|
| .cargo | ||
| .cloudflare | ||
| .config | ||
| .factory | ||
| .github | ||
| .zed | ||
| assets | ||
| ci | ||
| crates | ||
| docs | ||
| extensions | ||
| legal | ||
| nix | ||
| script | ||
| tooling | ||
| .git-blame-ignore-revs | ||
| .gitattributes | ||
| .gitignore | ||
| .mailmap | ||
| .prettierrc | ||
| .rules | ||
| AGENTS.md | ||
| Cargo.lock | ||
| Cargo.toml | ||
| CLAUDE.md | ||
| clippy.toml | ||
| CODE_OF_CONDUCT.md | ||
| codebook.toml | ||
| compose.yml | ||
| CONTRIBUTING.md | ||
| debug.plist | ||
| default.nix | ||
| Dockerfile-collab | ||
| Dockerfile-collab.dockerignore | ||
| Dockerfile-cross.dockerignore | ||
| Dockerfile-distros | ||
| Dockerfile-distros.dockerignore | ||
| flake.lock | ||
| flake.nix | ||
| GEMINI.md | ||
| LICENSE-AGPL | ||
| LICENSE-APACHE | ||
| LICENSE-GPL | ||
| livekit.yaml | ||
| lychee.toml | ||
| Procfile | ||
| Procfile.all | ||
| Procfile.web | ||
| README.md | ||
| renovate.json | ||
| REVIEWERS.conl | ||
| rust-toolchain.toml | ||
| rustfmt.toml | ||
| shell.nix | ||
| typos.toml | ||
Zed
Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Installation
On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).
Other platforms are not yet available:
- Web (tracking issue)
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 specifiederror for a crate you've created? If so, addpublish = falseunder[package]in your crate's Cargo.toml. - Is the error
failed to satisfy license requirementsfor 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 theacceptedarray inscript/licenses/zed-licenses.toml. - Is
cargo-aboutunable to find the license for a dependency? If so, add a clarification field at the end ofscript/licenses/zed-licenses.toml, as specified in the cargo-about book.
Sponsorship
Zed is developed by Zed Industries, Inc., a for-profit company.
If you’d like to financially support the project, you can do so via GitHub Sponsors. Sponsorships go directly to Zed Industries and are used as general company revenue. There are no perks or entitlements associated with sponsorship.