refactor(panel): pull out some repeated code into their own functions#59
Merged
dlyongemallo merged 2 commits intomainfrom Mar 27, 2026
Merged
refactor(panel): pull out some repeated code into their own functions#59dlyongemallo merged 2 commits intomainfrom
dlyongemallo merged 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors Diffview’s panel implementations to reduce duplicated logic by extracting repeated keymap-application and file-component construction code into reusable helpers.
Changes:
- Added
Panel:apply_keymaps()to centralize applying configured buffer-local keymaps (with merged default options). - Refactored
FilePanel:update_components()to use small helpers for list/tree component schema construction. - Added functional tests covering
FilePanel:update_components()behavior (list/tree) andPanel:apply_keymaps()option-merging behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
lua/diffview/ui/panel.lua |
Adds Panel:apply_keymaps() helper to apply keymaps from config sections with merged defaults. |
lua/diffview/scene/views/file_history/option_panel.lua |
Replaces inline keymap loop with self:apply_keymaps("option_panel"). |
lua/diffview/scene/views/file_history/file_history_panel.lua |
Uses apply_keymaps() and reuses returned config for find_*_keymap lookups. |
lua/diffview/scene/views/diff/file_panel.lua |
Uses apply_keymaps() and extracts list/tree component-building into local helpers. |
lua/diffview/tests/functional/panel_spec.lua |
Adds functional tests for FilePanel:update_components() and Panel:apply_keymaps(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c00f1f9 to
c45be2f
Compare
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.
No description provided.