Skip to content

Commit 083682e

Browse files
committed
Address latest CodeRabbit review comments
- Fix test assertion: use assert.is_nil instead of assert.is_false for pattern matching - Fix autocommand collision: use unique group names per buffer instance - Remove trailing whitespace from test file These changes ensure multi-instance autocommands don't interfere with each other and fix the test assertion logic for buffer name sanitization validation.
1 parent 5dd2196 commit 083682e

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

lua/claude-code/keymaps.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function M.setup_terminal_navigation(claude_code, config)
9494
local buf = current_instance and claude_code.claude_code.instances[current_instance]
9595
if buf and vim.api.nvim_buf_is_valid(buf) then
9696
-- Create autocommand to enter insert mode when the terminal window gets focus
97-
local augroup = vim.api.nvim_create_augroup('ClaudeCodeTerminalFocus', { clear = true })
97+
local augroup = vim.api.nvim_create_augroup('ClaudeCodeTerminalFocus_' .. buf, { clear = true })
9898

9999
-- Set up multiple events for more reliable focus detection
100100
vim.api.nvim_create_autocmd(

tests/spec/terminal_spec.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ describe('terminal module', function()
132132

133133
-- Current instance should be set
134134
assert.is_not_nil(claude_code.claude_code.current_instance, 'Current instance should be set')
135-
135+
136136
-- Instance should be created in instances table
137137
local current_instance = claude_code.claude_code.current_instance
138138
assert.is_not_nil(claude_code.claude_code.instances[current_instance], 'Instance buffer should be set')
@@ -217,7 +217,7 @@ describe('terminal module', function()
217217
-- Use an instance ID with special characters
218218
config.git.use_git_root = false
219219
config.git.multi_instance = true
220-
220+
221221
-- Mock getcwd to return path with special characters
222222
_G.vim.fn.getcwd = function()
223223
return '/test/path with spaces/and-symbols!'
@@ -232,7 +232,7 @@ describe('terminal module', function()
232232
if cmd:match('file claude%-code%-.*') then
233233
file_cmd_found = true
234234
-- Ensure no special characters remain
235-
assert.is_false(cmd:match('[^%w%-_]'), 'Buffer name should not contain special characters')
235+
assert.is_nil(cmd:match('[^%w%-_]'), 'Buffer name should not contain special characters')
236236
break
237237
end
238238
end
@@ -244,7 +244,7 @@ describe('terminal module', function()
244244
-- Setup invalid buffer in instances
245245
local instance_id = '/test/git/root'
246246
claude_code.claude_code.instances[instance_id] = 999 -- Invalid buffer number
247-
247+
248248
-- Mock nvim_buf_is_valid to return false for this buffer
249249
_G.vim.api.nvim_buf_is_valid = function(bufnr)
250250
return bufnr ~= 999

0 commit comments

Comments
 (0)