Skip to content

bug: attach to wrong buffers due to the autocmd #536

Description

@Kaiser-Yang

The below code is from the repository:

  vim.api.nvim_create_autocmd("FileType", {
    group = M.augroup,
    callback = vim.schedule_wrap(function()
      M.buf_attach()
    end),
  })

For this code, if there are some buffers whose filetype changed, this autocmd will try to attach to the current buffer even if the filetype is trigger by other buffers.

For example:

  1. I use :Copilot dettach to detach from a large file.
  2. Then I do something that will let 'noice.nvim' give me a notification.
  3. The filetype autocmd is triggered due to the notification buffer's filetype is set to 'Noice'.
  4. And copilot will attach to current large buffer, which I do not want copilot to attach.

The solution is very simple, there should be added one more parameter for attach a specific buffer, and use ev.buf to specify the buffer instead of current buffer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions