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>
This commit is contained in:
@@ -1922,6 +1922,7 @@ fn open_bundled_file(
|
||||
let mut editor =
|
||||
Editor::for_multibuffer(buffer, Some(project.clone()), window, cx);
|
||||
editor.set_read_only(true);
|
||||
editor.set_should_serialize(false, cx);
|
||||
editor.set_breadcrumb_header(title.into());
|
||||
editor
|
||||
})),
|
||||
|
||||
Reference in New Issue
Block a user