-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up Pane #2494
Clean up Pane #2494
Conversation
Having separate Horizontal/Vertical versions made it hard to manage, and App.cpp already made use of Pane::SplitState so it made sense to have that be the descriminator
Split was used as a noun in Tab but a verb in Pane, which felt odd
Improves readibility. All 'low hanging fruit' cases where the 'if' was returning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, but this is @zadjii-msft's world so I'd like to see his review before the final merge.
// our separator _is_ the correct direction, then we should be the pane | ||
// to resize. Otherwise, just return false, as we couldn't handle it | ||
// either. | ||
if ((!_firstChild->_IsLeaf()) && _firstChild->_HasFocusedChild()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern ("find the non-leaf's child, if it has one") appears a lot. Is there a way to pull it out into a helper? I know that we do slightly different things with each one, but the pattern looks the same:
if(!<x>.leaf && <x>.child) {
make <x> do <A>, or do <_A> ourselves
}
perhaps we can:
auto x = _findFirstChildPaneMatchingThoseCriteriaOrNot();
return x.has_value() && x->A() || _A();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I'm happy with this - much cleaner than before. Thanks!
Thanks for the contribution, as always! 😄 |
🎉 Handy links: |
Cleanup of Pane.cpp based on conversations in #2450
Summary of the Pull Request
Split{Horizontal,Vertical}
methods into a single method that acceptsPane::SplitState
Tab::(Can)AddSplit
to(Can)SplitPane
to keep the verb/noun usage consistent with Pane.cppelse
statements where theif
always returnsWhen reviewing, it might be easier to split into renames and tidy up
Each change has been committed separately to make them easier to rebase out if you're not happy with them, but feel free to squash them when merging.
References
#2450
PR Checklist
Detailed Description of the Pull Request / Additional comments
All covered by the "Summary" above.
Validation Steps Performed
Simple usage of the terminal, and hammering the split feature to ensure it still works (including the previously fixed crash fixed by #2450)