fix: defer BufDelete handler to ignore buflisted changes from scope-nvim#13
Closed
fix: defer BufDelete handler to ignore buflisted changes from scope-nvim#13
Conversation
Set bufhidden=hide to prevent the terminal buffer from being unloaded when it leaves the current window (e.g. during :tabnew). Add a BufWinEnter autocmd to re-apply window-local options and trigger a daemon redraw when the buffer re-enters a window after a tab switch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
buflisted=falseを設定 →BufDelete発火 → pterm のM.detach()が bridge を kill → ターミナル消滅BufDeleteコールバックをvim.scheduleで遅延させ、バッファがvalidかつloadedなら(単なる unlisting)detach をスキップ。真の削除(:bdelete/:bwipeout)時のみ detach を実行Root cause
scope-nvim scopes buffers per tab page by toggling
buflistedonTabLeave/TabEnter. Settingbuflisted=falsefiresBufDelete, which pterm interpreted as true buffer deletion — callingM.detach(), killing the bridge (SIGHUP exit code 129), and wiping the buffer.Built-in
:terminalis unaffected because it has noBufDeleteautocmd handler.Test plan
:Pterm→:tabnew→:tabprevでターミナルが正しく表示されることを確認:Pterm→:bdelete!でバッファが正しく削除・detach されることを確認:Pterm→ シェルでexit→:bdeleteで正しくクリーンアップされることを確認🤖 Generated with Claude Code