You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(preview): fire after_file_open on escalation; single source of truth
Two related changes to the preview/after_file_open machinery.
1. Escalation now fires the deferred hook. Previewing a file defers
`after_file_open`; previously, escalating that preview to a permanent
buffer (editing it, Enter, focusing away) never fired it at all — so a
file you preview-then-commit diverged from one you open directly, and
plugin side effects keyed on the hook (csharp `dotnet restore`, the
asm-lsp config offer, git_explorer refresh) silently never ran. The
`promote_*` methods now fire the deferred hook at the moment of
commitment, so the hook fires exactly once per buffer whether it was
opened directly or escalated from a preview.
2. Fewer, non-redundant states. Preview was tracked in three places that
could drift: `Window.preview` (the anchored (split, buffer)), a
per-buffer `BufferMetadata.is_preview` bool, and the `opening_as_preview`
open-time flag. Collapsed to one source of truth:
- `Window.preview: Option<(LeafId, BufferId)>` is now the only preview
state. "Two previews", "orphan preview flag", and "flag disagrees with
the anchored preview" are no longer representable. `is_buffer_preview`
and the tab renderer derive from it (the renderer takes a
`preview_buffer` argument threaded from `window.preview`).
- `opening_as_preview` (ambient mutable flag) is replaced by an explicit
`OpenKind::{Commit, Preview}` value threaded through the open path, so
the hook-deferral intent travels as an argument rather than window
state read out of band.
Because the single `after_file_open` fire site keys deferral off `OpenKind`
and re-fires off `Window.preview` at promotion, exactly-once holds
structurally with no "hook already fired" bookkeeping: a directly-opened
buffer is never the preview, and a promoted buffer is cleared from
`Window.preview`, so a later promote is a no-op.
The e2e suite adds the escalation case (preview → edit → hook fires) next to
the existing preview-suppression case; it times out without the fire-on-
promote change and passes with it.
https://claude.ai/code/session_01KdY8xi7GwhBTJueszhwGXB
0 commit comments