refactor(layout): pull out some repeated code into their own functions#58
Merged
dlyongemallo merged 2 commits intomainfrom Mar 27, 2026
Merged
refactor(layout): pull out some repeated code into their own functions#58dlyongemallo merged 2 commits intomainfrom
dlyongemallo merged 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors diff layout implementations to reduce duplicated logic by centralizing common file-assignment and window-creation behavior in the base Layout, and adds functional coverage for the new shared helpers.
Changes:
- Introduces
Layout:set_file_for(), a defaultLayout.use_entry(), andLayout.create_wins()to consolidate repeated per-layout logic. - Adds
symbolsdeclarations toDiff1–Diff4and updates concrete layouts to usecreate_wins()instead of bespoke window split code. - Expands functional tests to cover symbols,
set_file_for(), andcreate_wins()(mocked + integration with real splits).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| lua/diffview/scene/layout.lua | Adds shared helpers (set_file_for, default use_entry, create_wins) to eliminate repeated logic in concrete layouts. |
| lua/diffview/scene/layouts/diff_1.lua | Defines symbols and switches layout creation to create_wins(). |
| lua/diffview/scene/layouts/diff_2.lua | Defines symbols and removes now-redundant per-layout use_entry/file setter logic. |
| lua/diffview/scene/layouts/diff_2_hor.lua | Refactors window creation to create_wins() for horizontal 2-way layout. |
| lua/diffview/scene/layouts/diff_2_ver.lua | Refactors window creation to create_wins() for vertical 2-way layout. |
| lua/diffview/scene/layouts/diff_3.lua | Defines symbols and removes now-redundant per-layout use_entry/file setter logic. |
| lua/diffview/scene/layouts/diff_3_hor.lua | Refactors window creation to create_wins() for horizontal 3-way layout. |
| lua/diffview/scene/layouts/diff_3_mixed.lua | Refactors window creation to create_wins() for mixed 3-way layout (non-trivial creation order). |
| lua/diffview/scene/layouts/diff_3_ver.lua | Refactors window creation to create_wins() for vertical 3-way layout. |
| lua/diffview/scene/layouts/diff_4.lua | Defines symbols and removes now-redundant per-layout use_entry/file setter logic. |
| lua/diffview/scene/layouts/diff_4_mixed.lua | Refactors window creation to create_wins() for mixed 4-way layout (non-trivial creation order). |
| lua/diffview/tests/functional/layouts_spec.lua | Adds functional tests for symbols, set_file_for(), and create_wins() (mock + real-window integration). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.