Skip to content

Fix settings file restored to both panes after restart#50842

Merged
Veykril merged 1 commit intozed-industries:mainfrom
iam-liam:serialisation-settings-file
Mar 17, 2026
Merged

Fix settings file restored to both panes after restart#50842
Veykril merged 1 commit intozed-industries:mainfrom
iam-liam:serialisation-settings-file

Conversation

@iam-liam
Copy link
Copy Markdown
Contributor

@iam-liam iam-liam commented Mar 5, 2026

Closes #35947

Summary

When a settings file was moved to a second pane and Zed restarted, the file appeared in both panes. Closing it in one pane would close it in the other.

Root cause

Editor::deserialize restored standalone files (like settings.json) by calling workspace.open_abs_path(), which routes through open_path_previewpane.open_item(), adding the editor to the workspace's default pane. The caller (SerializedPane::deserialize_to) then also adds the item to the target pane, so it ends up in two panes.

This also caused the SQL constraint violations @MrSubidubi noted: the items table has PRIMARY KEY(item_id, workspace_id), so the duplicate triggers errors on the next serialisation cycle.

Fix

Replace workspace.open_abs_path() with project.open_local_buffer(), which opens the buffer without touching any pane. Pane placement is left to deserialize_to.

settings_dup_zed.mp4

Test plan

  • Reproduced the original bug (settings file duplicated across panes after restart)
  • Verified the fix: file restores only to the correct pane
  • Added regression test (test_deserialize_non_worktree_file_does_not_add_to_pane)
  • Existing items::tests::test_deserialize passes (all 6 cases)
  • cargo clippy -p editor clean

Release Notes:

  • Fixed settings file being restored to multiple panes after restart
    (#35947).

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 5, 2026
@iam-liam iam-liam marked this pull request as ready for review March 5, 2026 16:42
@zelenenka zelenenka added the guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions label Mar 16, 2026
Copy link
Copy Markdown
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Veykril
Copy link
Copy Markdown
Member

Veykril commented Mar 17, 2026

needs a rebase

@Veykril Veykril self-assigned this Mar 17, 2026
When deserializing a non-worktree file (e.g. settings.json),
Editor::deserialize called workspace.open_abs_path() which had the side
effect of adding the item to the default pane. The caller
(deserialize_to) then also added the item to the target pane, resulting
in the file appearing in two panes after restart.

Replace open_abs_path() with project.open_local_buffer() to open the
buffer without pane side effects, matching the in-worktree code path.

Closes zed-industries#35947

Liam
@iam-liam iam-liam force-pushed the serialisation-settings-file branch from 02e4d05 to 3a6ed4b Compare March 17, 2026 11:03
@iam-liam
Copy link
Copy Markdown
Contributor Author

@Veykril just rebased, let me know if there are any issues

@Veykril Veykril enabled auto-merge (squash) March 17, 2026 11:31
@Veykril Veykril merged commit 234c705 into zed-industries:main Mar 17, 2026
29 checks passed
@iam-liam iam-liam deleted the serialisation-settings-file branch March 19, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settings file is restored to both panes after restart, closing in 1st pane closes in 2nd pane

3 participants