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 lua/claudecode/terminal/native.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ local function open_terminal(cmd_string, env_table, effective_config, focus)
winid = new_winid
bufnr = vim.api.nvim_get_current_buf()
vim.bo[bufnr].bufhidden = "hide"
vim.bo[bufnr].filetype = "claudecode"
-- buftype=terminal is set by termopen

if focus then
Expand Down
1 change: 1 addition & 0 deletions lua/claudecode/terminal/snacks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ function M.open(cmd_string, env_table, config, focus)
if term_instance and term_instance:buf_valid() then
setup_terminal_events(term_instance, config)
terminal = term_instance
vim.bo[term_instance.buf].filetype = "claudecode"
else
terminal = nil
local logger = require("claudecode.logger")
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/native_terminal_toggle_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,20 @@ describe("claudecode.terminal.native toggle behavior", function()
-- Should have created terminal and have active buffer
assert.is_not_nil(native_provider.get_active_bufnr())
end)

it("should set filetype to claudecode on the terminal buffer", function()
local cmd_string = "claude"
local env_table = { TEST = "value" }
local config = { split_side = "right", split_width_percentage = 0.3 }

native_provider.open(cmd_string, env_table, config)

local bufnr = native_provider.get_active_bufnr()
assert.is_not_nil(bufnr)

local mock_state = _G.get_mock_state()
assert.are.equal("claudecode", mock_state.buffers[bufnr].options.filetype)
end)
end)

describe("toggle with existing hidden terminal", function()
Expand Down