-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add the ability to split a pane and put the new pane first. #11145
Conversation
src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h
Show resolved
Hide resolved
Don't forget to update the docs repo. |
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.
Meh, my comment is nitpicking over internal data structures, which doesn't terribly matter.
@@ -363,10 +363,14 @@ JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::ResizeDirection) | |||
// Possible SplitState values | |||
JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::SplitState) | |||
{ | |||
JSON_MAPPINGS(3) = { | |||
JSON_MAPPINGS(7) = { | |||
pair_type{ "vertical", ValueType::Vertical }, |
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.
So you might be able to make some of this code easier! We could get rid of SplitState::Horizontal
and Vertical
, but leave the serializations there. So you'd have
pair_type{ "vertical", ValueType::Right },
pair_type{ "horizontal", ValueType::Down },
Then we wouldn't need to keep those legacy enum values internally, but we could keep them in the json deserialization.
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.
Oh, but we do use SplitState::Horizontal/Vertical
for the actual internal "which way is this pane's divider". Hmm. Then maybe it makes more sense to have two types
- one for "which direction has a user asked to split this pane in" ("up"/"down"/"left"/"right", "auto", "horizontal"=="down", "vertical"="right")
- the other is "which direction is this pane's divider" (
Horizontal
,Vertical
)
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.
Would this end up with us serializing "right" as "horizontal" accidentally? That's why I didn't do that in the first place. If that isn't a problem I could split this into SplitDirection
and SplitState
.
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 did the refactor to make a separate SplitDirection
that is used for SplitPaneArgs, and then an internal to pane SplitState
that the direction gets converted to. I confirmed that SplitDirection
deserializes "horizontal" and "vertical" as "down" and "right" directions appropriately.
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.
Also confirmed that a user setting for a vertical
hotkey overrides (but displays as) a right
split.
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 need to remember to not get enticed by "small" refactoring in the future since the changes are always bigger than I expect them to be.
@@ -335,7 +335,11 @@ | |||
|
|||
// Pane Management | |||
{ "command": "closePane", "keys": "ctrl+shift+w" }, | |||
{ "command": { "action": "splitPane", "split": "up" } }, |
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.
May want to stick these under "SplitPaneParentCommandName"
instead, so they show up in the nested split pane commands
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.
Instead or in addition to?
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 replaced the current split horizontal/vertical with down
/right
, and added those as options to the extra menu below.
src/cascadia/TerminalApp/Pane.cpp
Outdated
if (splitType == SplitState::Up || splitType == SplitState::Left) | ||
{ | ||
std::swap(_firstChild, _secondChild); | ||
} |
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.
Wow this is really the entire meat of this PR isn't it. So simple
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.
10 lines of actual code changes, 200 lines of boilerplate and refactoring :)
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 forgot about all of the unit tests that needed to be updated, so that is an extra 200 lines of refactoring changes.
…orizontal/vertical map properly. Updated one of the command tests to actually check the directional versions map correctly.
I /think/ I fixed all of the tests related to this. It is hard to tell because when running locally there were a number of other tests that were failing that were completely unrelated. This might as well be an entirely new PR at this point so re-review at your leisure. |
Does the azure build run with particular compiler settings? Trying to build locally I have no problems.
|
Oh, the azure builds applies the pr changes on top of |
@msftbot merge this in 5 minutes |
Hello @carlos-zamora! Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:
If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you". |
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 didn't review this before it merged, but I have this to say: I would have had not a single additional comment, and the refactoring in here is absolute goodness. Thank you.
🎉 Handy links: |
Summary of the Pull Request
Adds directional modifiers for SplitState and convert those to the appropriate horizontal/vertical when splitting a pane.
References
PR Checklist
Detailed Description of the Pull Request / Additional comments
"vertical" and "horizontal" splits were removed from
defaults.json
, but code was added to parse those asright
anddown
respectively. It is also the case that if a user has a custom hotkey forsplit: vertical
it will override the default forsplit: right
.Validation Steps Performed
Split the pane using each of the new directional movements