-
Notifications
You must be signed in to change notification settings - Fork 9.1k
minor refactor: Move Tab management into its own file #9629
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
Conversation
carlos-zamora
left a comment
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.
Yeeeeaaaaah. We should probably break up TerminalPage more haha.
Curious: does breaking it up help out with glomming & tab tear off at all? Maybe there's ways to shoe-horn some of that work in that effort?
If not, I say we file a CodeHealth task to figure out how to clean up TerminalPage a bit. Just to break up the responsibilities better.
maybe? We're way too far out to know for sure. Better encapsulation is always good though. |
| { | ||
| // Since _RemoveTab is asynchronous, create a snapshot of the tabs we want to remove | ||
| std::vector<winrt::TerminalApp::TabBase> tabsToRemove; | ||
| std::copy(begin(_tabs), end(_tabs), std::back_inserter(tabsToRemove)); |
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.
clever
|
Conflict resolution req'd. |
|
Hello @zadjii-msft! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
I think we can all agree that
TerminalPage.cppis an unruly beast of afile. It's got everything. It does everything. It can sometimes be a bit
hard to work with, because of simply how big it is. This PR tries to
alleviate this by making
TerminalPage.cppjust a little smaller. Itdoes so by moving pretty much everything related to tab management into
its own file,
TabManagement.cpp. These methods that have moved are allthe same as they were before, and they're still members of
TerminalPage. But now they're all in one place.I tried to move all the references to
_tabsinTerminalPage.cpp, butthere's still a few that I left behind. Mostly because I felt that
moving those would be too gnarly a code change for an otherwise simple
cut&paste PR.
There are a few new methods I introduced:
_TabDragStartedand_TabDragCompleted: These were lambdas before,promoted to full methods.
_DismissTabContextMenus: Remove all the right-click context menusfrom the tabs
_FocusCurrentTab: This one's a bit trickier, we were actually doingthis in a few different places, so I tried consolidating.
_HasMultipleTabs: This doesn't need explaining._RemoveAllTabs: Really, just encapsulation for the sake of removinga
_tabsfromTerminalPage.cpp_ResizeTabContent: Really, just encapsulation for the sake ofremoving a
_tabsfromTerminalPage.cppIn the future, some enterprising young soul could try promoting that
file to its own class, and hiding
_tabs(and_mruTabs) inside it.Probably would need to take a reference to TerminalPage's
_tabViewand_newTabButton. I'm not doing that right now, because I already hatethe idea of the ...
... I'm making you look at already.
Other thoughts
Some of the calls might be a little arbitrary -
☺️
_OpenNewTaband_CreateNewTabFromSettingsprobably should stay inTerminalPage? Orat least elements of those might need to get split up better. Similarly
TerminalPage::_OpenSettingsUIstayed inTerminalPage.cpp, but itdoes a lot of the same work as
_CreateNewTabFromSettings. I'm notsaying this is the definitive places for these methods - it's code we're
working with, not stone