# Do not serialize buffers containing bundled files \(\#38102\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/7a37dd9433dde95c1e03496326a870dcfaced504)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 7a37dd9433dde95c1e03496326a870dcfaced504

Requested commit: 7a37dd9433dde95c1e03496326a870dcfaced504

Commit: 7a37dd9433dde95c1e03496326a870dcfaced504

Tree: 9bb465e75e3fc89e88fbfb2683e25c6979719b7e

Author: ʟᴜɴᴇx

Committer: GitHub

## Message

````
Do not serialize buffers containing bundled files (#38102)

Fix bundled file persistence by introducing SerializationMode enum

Closes: #38094

What's the issue?

Opening bundled files like Default Key Bindings
(zed://settings/keymap-default.json) was causing SQLite foreign key
constraint errors. The editor was trying to save state for these
read-only assets just like regular files, but since bundled files don't
have database entries, the foreign key constraint would fail.

The fix

Replaced the boolean serialize_dirty_buffers flag with a type-safe
SerializationMode enum:

```rust
pub enum SerializationMode {
    Enabled,   // Regular files persist across sessions
    Disabled,  // Bundled files don't persist
}
```

This prevents serialization at the source: workspace_id() returns None
for disabled editors, serialize() bails early, and should_serialize()
returns false. When opening bundled files, we set the mode to Disabled
from the start, so they're treated as transient views that never
interact with the persistence layer.

Changes

- editor.rs: Added SerializationMode enum and updated serialization
methods to respect it
- items.rs: Guarded should_serialize() to prevent disabled editors from
being serialized
- zed.rs: Set SerializationMode::Disabled in open_bundled_file()

Result

Bundled files open cleanly without SQLite errors and don't persist
across workspace reloads (expected behavior). Regular file persistence
remains unaffected.

Release Notes: Fixed SQLite foreign key constraint errors when opening
bundled files like Default Key Bindings.

---------

Co-authored-by: MrSubidubi <finn@zed.dev>
````

## Parents

- [a7163623e70dc1e7298de5334a96782148641e35](https://git.cafe/gitcafe/zed/commit/a7163623e70dc1e7298de5334a96782148641e35?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/7a37dd9433dde95c1e03496326a870dcfaced504?format=markdown)
