feat: reload edited buffer after Claude writes to disk#23
feat: reload edited buffer after Claude writes to disk#23kam-hak wants to merge 1 commit intoCannon07:mainfrom
Conversation
|
Self-review caught that |
Apply the four fixes from the PR review cycle: - PR Cannon07#20: restore post-cleanup reveal inside is_open() guard so newly-created files appear in neo-tree after accept. - PR Cannon07#21: replace jq '// true' with explicit conditional so reveal=false config is actually honored (// treats false like null). - PR Cannon07#21/Cannon07#24: restore walk-up-to-parent logic for created files so neo-tree can expand paths that don't exist on disk yet. - PR Cannon07#23: replace bufnr(path) with literal canonical-path comparison; bufnr does regex matching and mis-matches paths with metacharacters. - PR Cannon07#24: drop the is_mac + :lower() hack; fs_realpath already returns the filesystem canonical form, and lowercasing produces false positives on case-sensitive filesystems.
Fires checktime on the buffer matching the edited file so changes appear without requiring focus/blur. Runs regardless of diff state (visible_only mode, manually-closed tab, etc) — Claude wrote the file whether or not a preview was shown. Iterates nvim_list_bufs() and compares canonical paths (fs_realpath) instead of vim.fn.bufnr(), which does partial+regex matching on buffer names and mis-matches paths containing regex metacharacters (e.g. /tmp/foo[1].md).
8c539b9 to
cc606ad
Compare
|
Rebased onto main, squashed to a single commit. Moved the buffer reload outside the |
|
Thanks for the PR! I tested this on my end but wasn't able to reproduce the stale buffer issue — the buffer seems to reload correctly after Claude edits, even without this change. Could you share the exact steps to reproduce the stale buffer (which file layout, split/tab setup, etc.) Once I can reproduce the issue, I'd be happy to move forward with this. Thanks! |
|
This happened to me when having a buffer open and then opening claude code inside neovim using |
|
Thanks for the repro @crisecheverria! Adding vim.o.autoread = true
vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter", "CursorHold", "TermLeave" }, {
command = "checktime",
})I'll update the Recommended companion settings in the README to include Adding |
|
Hey @kam-hak, Happy to merge this in. That said, the codebase has changed quite a bit since your last rebase. The buffer reload logic would need to go into Would you be up for rebasing again, or would you prefer I take over from here and integrate the change? Either way works — the |
Hey! Yea sorry this is stale now. I wouldn't be able to do this for about a week so please feel free to integrate/merge, or i can do it around Friday if you end up being busy. |
Problem
After Claude edits a file that's open in nvim, the buffer shows stale content until the user manually focuses it. Nvim's
autoreadonly checks on focus/CursorHold events, so edits made by an external process (Claude CLI) don't appear immediately.Fix
After PostToolUse fires, send a targeted
checktimecall via RPC for just the edited file's buffer. Other open buffers are not affected.Test plan