Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- New `split_ratio` config option to replace `height_ratio` for better handling of both horizontal and vertical splits
- Buffer is now unlisted by default (doesn't appear in `:ls` output)

### Fixed

Expand Down
8 changes: 3 additions & 5 deletions lua/claude-code/terminal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ function M.force_insert_mode(claude_code, config)
-- Check if current buffer is any of our Claude instances
local is_claude_instance = false
for _, bufnr in pairs(claude_code.claude_code.instances) do
if bufnr
and bufnr == current_bufnr
and vim.api.nvim_buf_is_valid(bufnr)
then
if bufnr and bufnr == current_bufnr and vim.api.nvim_buf_is_valid(bufnr) then
is_claude_instance = true
break
end
Expand Down Expand Up @@ -110,7 +107,7 @@ function M.toggle(claude_code, config, git)
end
else
-- Use a fixed ID for single instance mode
instance_id = "global"
instance_id = 'global'
end

claude_code.claude_code.current_instance = instance_id
Expand Down Expand Up @@ -155,6 +152,7 @@ function M.toggle(claude_code, config, git)

vim.cmd(cmd)
vim.cmd 'setlocal bufhidden=hide'
vim.cmd 'setlocal nobuflisted'

-- Create a unique buffer name (or a standard one in single instance mode)
local buffer_name
Expand Down
23 changes: 22 additions & 1 deletion tests/spec/terminal_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,25 @@ describe('terminal module', function()
assert.is_true(success, 'Force insert mode function should run without error')
end)
end)
end)

describe('buffer listing', function()
it('should set buffer as nobuflisted when creating terminal', function()
-- Claude Code is not running (bufnr is nil)
claude_code.claude_code.bufnr = nil

-- Call toggle
terminal.toggle(claude_code, config, git)

-- Check that nobuflisted command was called
local nobuflisted_found = false
for _, cmd in ipairs(vim_cmd_calls) do
if cmd == 'setlocal nobuflisted' then
nobuflisted_found = true
break
end
end

assert.is_true(nobuflisted_found, 'setlocal nobuflisted should be called')
end)
end)
end)