Skip to content

fix: defer BufDelete handler to ignore buflisted changes from scope-nvim#13

Closed
ttak0422 wants to merge 1 commit intomainfrom
fix/terminal-disappears-on-tab-switch
Closed

fix: defer BufDelete handler to ignore buflisted changes from scope-nvim#13
ttak0422 wants to merge 1 commit intomainfrom
fix/terminal-disappears-on-tab-switch

Conversation

@ttak0422
Copy link
Copy Markdown
Owner

@ttak0422 ttak0422 commented Mar 11, 2026

Summary

  • 原因: scope-nvim がタブ切り替え時に 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 buflisted on TabLeave/TabEnter. Setting buflisted=false fires BufDelete, which pterm interpreted as true buffer deletion — calling M.detach(), killing the bridge (SIGHUP exit code 129), and wiping the buffer.

Built-in :terminal is unaffected because it has no BufDelete autocmd handler.

Test plan

  • :Pterm:tabnew:tabprev でターミナルが正しく表示されることを確認
  • :Pterm:bdelete! でバッファが正しく削除・detach されることを確認
  • :Pterm → シェルで exit:bdelete で正しくクリーンアップされることを確認

🤖 Generated with Claude Code

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>
@ttak0422 ttak0422 closed this Mar 11, 2026
@ttak0422 ttak0422 changed the title fix: preserve terminal buffer and restore display on tab switch fix: defer BufDelete handler to ignore buflisted changes from scope-nvim Mar 11, 2026
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