# Fix settings file restored to both panes after restart \(\#50842\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 234c7057c4cfbbb1988d8b7fb60cc289a7488d49

Requested commit: 234c7057c4cfbbb1988d8b7fb60cc289a7488d49

Commit: 234c7057c4cfbbb1988d8b7fb60cc289a7488d49

Tree: 78421709159738a40a278baffed0411bc364fa4b

Author: iam-liam

Committer: GitHub

## Message

```
Fix settings file restored to both panes after restart (#50842)

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_preview` → `pane.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`.


https://github.com/user-attachments/assets/68d3c5b4-d002-429f-b907-ec21cb0019ec

## Test plan

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

Release Notes:

- Fixed settings file being restored to multiple panes after restart
  ([#35947](https://github.com/zed-industries/zed/issues/35947)).
```

## Parents

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

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