Improve tmux shared session detection

- Add case-insensitive check for 'shared' in session name
- Keep existing check for multiple attached clients
- Add documentation about vim.fn.confirm() keyboard shortcuts
- Update CLAUDE.md with nvdev testing workflow

This ensures the quit warning triggers for any session with 'shared'
in the name, not just sessions with multiple attachments.

Fixes #21

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
dlond 2025-08-20 21:40:30 +12:00 committed by Daniel Lond
parent ac77be6ede
commit f7e21a4a2a
2 changed files with 19 additions and 2 deletions

View file

@ -33,6 +33,12 @@ local function is_shared_tmux_session()
local output = handle:read('*a')
handle:close()
-- Check if session name contains "shared" (case insensitive)
if current_session:lower():find('shared') then
return true
end
-- Also check if multiple users are attached
for line in output:gmatch('[^\r\n]+') do
local session_name, attached_count = line:match('([^:]+):(%d+)')
if session_name == current_session and tonumber(attached_count) > 1 then
@ -50,10 +56,12 @@ vim.api.nvim_create_autocmd('VimLeavePre', {
local choice = vim.fn.confirm(
'You are in a shared tmux session. Other users may be affected.\nDo you really want to quit?',
'&Yes\n&No',
2
2 -- Default to No
)
-- vim.fn.confirm returns 1 for Yes, 2 for No, 0 for Esc
-- The & makes Y/y and N/n work as shortcuts (case-insensitive)
if choice ~= 1 then
return
return -- Prevent quit unless explicitly choosing Yes
end
end
end,