Skip to content

refactor(layout): pull out some repeated code into their own functions#58

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

refactor(layout): pull out some repeated code into their own functions#58
dlyongemallo merged 2 commits intomainfrom
refactor_diff_layouts

Conversation

@dlyongemallo
Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings March 24, 2026 11:30
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 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 default Layout.use_entry(), and Layout.create_wins() to consolidate repeated per-layout logic.
  • Adds symbols declarations to Diff1Diff4 and updates concrete layouts to use create_wins() instead of bespoke window split code.
  • Expands functional tests to cover symbols, set_file_for(), and create_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.

@dlyongemallo dlyongemallo merged commit e84b8d2 into main Mar 27, 2026
6 checks passed
@dlyongemallo dlyongemallo deleted the refactor_diff_layouts branch April 8, 2026 01:31
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