Skip to content

fix: apply diff keymaps to buffers that opened before the autocmd - #27

Open
KEY60228 wants to merge 1 commit into
mainfrom
fix/keymap-setup-timing
Open

fix: apply diff keymaps to buffers that opened before the autocmd#27
KEY60228 wants to merge 1 commit into
mainfrom
fix/keymap-setup-timing

Conversation

@KEY60228

Copy link
Copy Markdown
Owner

Summary

setup_diff_keymaps() is called after ui.open(), so the initial BufEnter for both diff panes fired before the BufEnter autocmd existed. As a result the focused pane had no buffer-local keymaps (<leader>rc etc.) right after :ReviewThemStart — they only appeared after switching windows once and re-entering the pane.

Extracts the mapping logic into an idempotent per-buffer function and, after registering the autocmd, applies it directly to any already-open reviewthem://old / reviewthem://new buffers. The fix is order-independent, so it also covers the resume path.

Test plan

Headless-nvim E2E: require("reviewthem").setup():ReviewThemStart in a fixture repo, then assert via nvim_buf_get_keymap() that the focused reviewthem://new buffer has the normal/visual "Add comment" and "Submit review" mappings immediately, and that the unfocused old pane has them too — all true (previously false without a window switch).

🤖 Generated with Claude Code

setup_diff_keymaps() was called after ui.open(), so the initial BufEnter
for both diff panes fired before the BufEnter autocmd existed. As a
result the focused pane had no buffer-local keymaps (<leader>rc etc.)
until the user switched windows once and re-entered it.

Extract the mapping logic into an idempotent per-buffer function and,
after registering the autocmd, apply it directly to any already-open
reviewthem://old / reviewthem://new buffers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant