Skip to content

Commit 343891a

Browse files
committed
fix: stop window vars from throwing tantrums
Turns out nvim_win_get_var was a drama queen, throwing exceptions whenever it couldn't find its precious variable - like a toddler having a meltdown when they can't find their favorite toy. Switched to vim.w, the more chill cousin who just returns nil and goes about their day when something's missing. Now our code won't have an existential crisis just because a directory hasn't changed. No more exception-al behavior, just peaceful, quiet coding.
1 parent 7ab495e commit 343891a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lua/CopilotChat/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ function M.setup(config)
13311331
group = augroup,
13321332
callback = function()
13331333
if vim.v.event and vim.v.event.cwd then
1334-
vim.api.nvim_win_set_var(0, 'cchat_cwd', vim.v.event.cwd)
1334+
vim.w.cchat_cwd = vim.v.event.cwd
13351335
end
13361336
end,
13371337
})

lua/CopilotChat/utils.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function M.win_cwd(winnr)
176176
return '.'
177177
end
178178

179-
local dir = vim.api.nvim_win_get_var(winnr, 'cchat_cwd')
179+
local dir = vim.w[winnr].cchat_cwd
180180
if not dir or dir == '' then
181181
return '.'
182182
end

0 commit comments

Comments
 (0)