Skip to content

Open non-writeable files in Capability::Read mode - #57202

Merged
Veykril merged 2 commits into
zed-industries:mainfrom
David3u:open-uneditable-files-in-uneditable-buffer
Jul 10, 2026
Merged

Open non-writeable files in Capability::Read mode#57202
Veykril merged 2 commits into
zed-industries:mainfrom
David3u:open-uneditable-files-in-uneditable-buffer

Conversation

@David3u

@David3u David3u commented May 19, 2026

Copy link
Copy Markdown
Contributor

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Closes #57174

Release Notes:

  • Open non-writeable files in Capability::Read mode

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 19, 2026
@smitbarmase smitbarmase added the area:fs Related to the fs crate. label May 29, 2026

@Veykril Veykril left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@Veykril
Veykril enabled auto-merge July 10, 2026 09:40
@Veykril Veykril self-assigned this Jul 10, 2026
@Veykril
Veykril added this pull request to the merge queue Jul 10, 2026
Merged via the queue into zed-industries:main with commit 60314a7 Jul 10, 2026
34 checks passed
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#57174

Release Notes:

- Open non-writeable files in Capability::Read mode

Co-authored-by: Lukas Wirth <lukas@zed.dev>
Pa1eShad0w added a commit to Pa1eShad0w/zed that referenced this pull request Aug 19, 2026
…e tab

Perforce keeps every file that is not open for edit read-only on disk. Since
upstream zed-industries#57202, which landed in v1.12.0 and reached this fork through the
v1.11 -> v1.15 uptake, a file that is read-only on disk opens in
Capability::Read: the tab gets a lock icon and the editor refuses keystrokes.

That deadlocks auto-checkout. Both hooks that run `p4 edit` are triggered by an
edit or a save, and neither can happen while the buffer is locked, so the user
has to click the lock by hand before they can work. The capability is also a
one-shot snapshot taken in `load_file` and is never recomputed, and
`BufferStore::open_buffer` returns the cached buffer for a path, so reopening
the file after a successful checkout keeps the stale lock.

`open_buffer` now peeks synchronously: a read-only file whose path resolves to
an already-resolved Perforce repository, with `perforce.edit_on_file_save` on,
opens editable. When the peek cannot answer - no repository discovered yet, or
its backend has not resolved - the buffer opens locked exactly as upstream does
and a background task settles it via `is_perforce_resolved`. Nothing on the
open path awaits Perforce: doing so would tie opening a file to `p4 info`
reaching the server, so a user whose server is unreachable could no longer open
files at all. `GitStore` retries the still-locked buffers when it discovers a
repository, which covers discovery racing session restore.

Only buffers this store locked itself are unlocked, and only while they are
still Capability::Read, so `worktree.read_only_files` and tabs the user locked
by hand are untouched. Git and non-VCS files keep upstream's behavior.

The decision itself is covered by tests in the crate's integration target; the
crate sets `[lib] test = false`, so a `#[cfg(test)]` module under `src/` would
never run.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
playdohface pushed a commit to playdohface/zed that referenced this pull request Aug 29, 2026
Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes zed-industries#57174

Release Notes:

- Open non-writeable files in Capability::Read mode

Co-authored-by: Lukas Wirth <lukas@zed.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:fs Related to the fs crate. cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Files without write permissions are opened in an editable buffer

4 participants