neovim / neovim/node-client

Bug: expand autocmd with <abuf> is wrong for BufUnload

Open
#58 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
537
Forks
57
Avg merge
1h 6m
Merged PRs (30d)
6

Description

  @Autocmd('BufUnload', {
    sync: true,
    pattern: '*',
    eval: 'expand("<abuf>")'
  })
  public async onBufUnload(bufnr: string):Promise<void> {
    logger.debug(`file: ${bufnr} remove`)
  }

The bufnr here is always the buffer number of current buffer number, but it should be the buffer number of removed buffer.

autocmd BufUnload * call s:OnUnload()
function! s:OnUnload()
  echo +expand('<abuf>')
endfunction

vim script doesn't have this problem.

BTW: <afile> is neither correct.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the TypeScript @Autocmd entry point and trace how eval: 'expand("")' is evaluated for BufUnload; compare it with the Vimscript example and the case. Done when unload callbacks receive the removed buffer and file values rather than the current buffer, with regression coverage for both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.