Skip to content

fix(editor): refresh plugins after buffer replacement - #310

Merged
fcoury-oai merged 1 commit into
mainfrom
fcoury/barbecue-buffer-identity
Aug 22, 2026
Merged

fcoury-oai merged 1 commit into
mainfrom
fcoury/barbecue-buffer-identity

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

When :bd replaces the current buffer with another buffer at the same numeric index, plugin change detection misses the transition. This can leave Barbecue rendering the deleted document's path and symbols even though the editor has switched to [No Name] or another file.

This change records the active buffer's stable BufferId in editor event snapshots and treats either an index change or an identity change as a buffer change. Plugin window snapshots are refreshed and window:buffer_changed is emitted for same-index replacements. The regression coverage exercises both deleting the sole file and deleting a non-final buffer whose successor compacts into the same slot.

How to Test

  1. Run cargo test deleting_buffer_notifies_plugins_when_replacement_reuses_its_index.
    Expected: both same-index replacement cases pass and emit window:buffer_changed.
  2. Build with cargo build --bin red, launch ./target/debug/red src/editor.rs, and run :bd.
    Expected: Barbecue and the statusline both change from src/editor.rs to [No Name].
  3. Launch ./target/debug/red src/editor.rs, run :e plugins/barbecue.hk, :buffer-prev, then :bd.
    Expected: Barbecue and the statusline both change to plugins/barbecue.hk when it compacts into buffer index 0.

@fcoury-oai
fcoury-oai merged commit 61956bc into main Aug 22, 2026
10 checks passed
@fcoury-oai
fcoury-oai deleted the fcoury/barbecue-buffer-identity branch August 22, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant