openFile: nested write + BufWriteCmd handler can overwrite Claude's file during the acwrite step (known gap)

Aberta
#433 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
12/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
lua, neovim
Domínio
devtools

Direção de pesquisa

Start with the openFile paragraph of Side Effects in lua/claudecode/tools/README.md, then read earlier threads #408, #413 and #420 for the attempts already ruled out. The hard part is design: find a way to block writes of only the one buffer during the acwrite step without affecting other writes or prompts. Done means a documented, tested approach that keeps the E676 and E142 behaviour the issue describes.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

needs-triage

openFile can still write the user's unsaved text over the file Claude just changed, in one narrow case. This issue tracks it, because #413 and #420 only documented it.

When it happens. All three must hold:

  1. openFile runs its acwrite step for the buffer: the buffer was opened before its file existed, or 'eventignore' or 'eventignorewin' ignores FileChangedShell.
  2. A user autocommand with ++nested on BufEnter, BufWinEnter or BufLeave writes that buffer while openFile shows it.
  3. A user BufWriteCmd handler that matches the file (such as BufWriteCmd *) writes <afile>.

Without ++nested, or without a matching handler, the write fails with E676 and Claude's file stays. Before #408, Neovim stopped this write with E13.

What was tried.

  • Turning the global 'write' option off during the step (#413 first version) stopped the overwrite but made a common autocmd BufLeave * update autosave fail openFile with E142.
  • nowrite or nofile 'buftype' make 'modified' read as off, which loses unsaved text through other autocommands (#408 round 7).
  • readonly does not stop :w! and prompts with 'confirm'.
  • A BufWriteCmd guard of openFile's own runs after the user's BufWriteCmd *.

Where it is documented. lua/claudecode/tools/README.md, openFile paragraph of Side Effects.

A fix needs a way to block writes of this one buffer during the step without blocking or prompting other writes.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

Linguagem predominante
Lua
Estrelas
3.1k
Forks
223
Merge médio
6h 47min
PRs com merge (30d)
93

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

  • Sem Dockerfile nem arquivo Docker Compose
  • Sem modelo de pull request
  • Sem guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de coder/claudecode.nvim

Todas as issues de coder/claudecode.nvim

Issues semelhantes

Mais issues de Lua

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.