fix: apply diff keymaps to buffers that opened before the autocmd - #27
Open
KEY60228 wants to merge 1 commit into
Open
fix: apply diff keymaps to buffers that opened before the autocmd#27KEY60228 wants to merge 1 commit into
KEY60228 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
setup_diff_keymaps()is called afterui.open(), so the initialBufEnterfor both diff panes fired before the BufEnter autocmd existed. As a result the focused pane had no buffer-local keymaps (<leader>rcetc.) 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://newbuffers. The fix is order-independent, so it also covers the resume path.Test plan
Headless-nvim E2E:
require("reviewthem").setup()→:ReviewThemStartin a fixture repo, then assert vianvim_buf_get_keymap()that the focusedreviewthem://newbuffer 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