Skip to content
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

Merged
6 commits merged into from
Sep 15, 2021

Conversation

Rosefield
Copy link
Contributor

@Rosefield Rosefield commented Sep 4, 2021

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

  • Closes Choose Direction to Split Pane #4340
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Documentation updated. If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated.
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Detailed Description of the Pull Request / Additional comments

"vertical" and "horizontal" splits were removed from defaults.json, but code was added to parse those as right and down respectively. It is also the case that if a user has a custom hotkey for split: vertical it will override the default for split: right.

Validation Steps Performed

Split the pane using each of the new directional movements

@carlos-zamora
Copy link
Member

Don't forget to update the docs repo.

Rosefield added a commit to Rosefield/terminal-1 that referenced this pull request Sep 7, 2021
@zadjii-msft zadjii-msft self-assigned this Sep 9, 2021
@ghost ghost added Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Task It's a feature request, but it doesn't really need a major design. Priority-3 A description (P3) Product-Terminal The new Windows Terminal. labels Sep 12, 2021
Copy link
Member

@zadjii-msft zadjii-msft left a 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 },
Copy link
Member

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.

Copy link
Member

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)

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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" } },
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Comment on lines 2086 to 2089
if (splitType == SplitState::Up || splitType == SplitState::Left)
{
std::swap(_firstChild, _secondChild);
}
Copy link
Member

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

Copy link
Contributor Author

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 :)

Copy link
Contributor Author

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.

@zadjii-msft zadjii-msft removed their assignment Sep 14, 2021
…orizontal/vertical map properly. Updated one of the command tests to actually check the directional versions map correctly.
@Rosefield
Copy link
Contributor Author

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.

@Rosefield
Copy link
Contributor Author

Does the azure build run with particular compiler settings? Trying to build locally I have no problems.

Microsoft Visual Studio Community 2019
Version 16.10.4

@Rosefield
Copy link
Contributor Author

Oh, the azure builds applies the pr changes on top of main not the actual state of the branch. Interesting.

@carlos-zamora
Copy link
Member

@msftbot merge this in 5 minutes

@ghost ghost added the AutoMerge Marked for automatic merge by the bot when requirements are met label Sep 15, 2021
@ghost
Copy link

ghost commented Sep 15, 2021

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:

  • I won't merge this pull request until after the UTC date Wed, 15 Sep 2021 20:14:29 GMT, which is in 5 minutes

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".

@ghost ghost merged commit 87b695f into microsoft:main Sep 15, 2021
@Rosefield Rosefield deleted the feature/gh4340-directional-split branch September 15, 2021 20:15
Copy link
Member

@DHowett DHowett left a 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.

@ghost
Copy link

ghost commented Oct 20, 2021

🎉Windows Terminal Preview v1.12.2922.0 has been released which incorporates this pull request.:tada:

Handy links:

@ghost ghost mentioned this pull request Oct 20, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Task It's a feature request, but it doesn't really need a major design. Priority-3 A description (P3) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Choose Direction to Split Pane
4 participants