Skip to content

refactor(panel): pull out some repeated code into their own functions#59

Merged
dlyongemallo merged 2 commits intomainfrom
refactor_panels
Mar 27, 2026
Merged

refactor(panel): pull out some repeated code into their own functions#59
dlyongemallo merged 2 commits intomainfrom
refactor_panels

Conversation

@dlyongemallo
Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings March 24, 2026 11:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) and Panel: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.

Comment thread lua/diffview/tests/functional/panel_spec.lua Outdated
Comment thread lua/diffview/tests/functional/panel_spec.lua Outdated
Comment thread lua/diffview/tests/functional/panel_spec.lua
@dlyongemallo dlyongemallo merged commit b8c07c0 into main Mar 27, 2026
2 checks passed
@dlyongemallo dlyongemallo deleted the refactor_panels branch April 8, 2026 01:30
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.

2 participants