Skip to content

Commit 89c8ada

Browse files
powermanAntoineGS
authored andcommitted
fix: race in should_attach
1 parent 3061c49 commit 89c8ada

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Install the plugin with your preferred plugin manager.
5050
For example, with [packer.nvim](https://github.com/wbthomason/packer.nvim):
5151

5252
```lua
53-
use { "zbirenbaum/copilot.lua"
53+
use { "zbirenbaum/copilot.lua"
5454
requires = {
5555
"copilotlsp-nvim/copilot-lsp", -- (optional) for NES functionality
5656
},
@@ -198,14 +198,14 @@ require('copilot').setup({
198198
root_dir = function()
199199
return vim.fs.dirname(vim.fs.find(".git", { upward = true })[1])
200200
end,
201-
should_attach = function(_, _)
202-
if not vim.bo.buflisted then
201+
should_attach = function(buf_id, _)
202+
if not vim.bo[buf_id].buflisted then
203203
logger.debug("not attaching, buffer is not 'buflisted'")
204204
return false
205205
end
206206

207-
if vim.bo.buftype ~= "" then
208-
logger.debug("not attaching, buffer 'buftype' is " .. vim.bo.buftype)
207+
if vim.bo[buf_id].buftype ~= "" then
208+
logger.debug("not attaching, buffer 'buftype' is " .. vim.bo[buf_id].buftype)
209209
return false
210210
end
211211

lua/copilot/config/should_attach.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ local logger = require("copilot.logger")
44

55
local should_attach = {
66
---@type ShouldAttachFunc
7-
default = function(_, _)
8-
if not vim.bo.buflisted then
7+
default = function(buf_id, _)
8+
if not vim.bo[buf_id].buflisted then
99
logger.debug("not attaching, buffer is not 'buflisted'")
1010
return false
1111
end
1212

13-
if vim.bo.buftype ~= "" then
14-
logger.debug("not attaching, buffer 'buftype' is " .. vim.bo.buftype)
13+
if vim.bo[buf_id].buftype ~= "" then
14+
logger.debug("not attaching, buffer 'buftype' is " .. vim.bo[buf_id].buftype)
1515
return false
1616
end
1717

0 commit comments

Comments
 (0)