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

Support for navigating panes by MRU #8183

Merged
21 commits merged into from
Dec 11, 2020
Merged

Support for navigating panes by MRU #8183

21 commits merged into from
Dec 11, 2020

Conversation

PankajBhojwani
Copy link
Contributor

@PankajBhojwani PankajBhojwani commented Nov 6, 2020

Adds a "move to previous pane" and "move to next pane" keybinding, which
navigates to the last/first focused pane

We assign pane IDs on creation and maintain a vector of active pane IDs
in MRU order. Navigating panes by MRU then requires specifying which
pane ID we want to focus.

From our offline discussion (thanks @zadjii-msft for the concise
description):

For the record, the full spec I'm imagining is:

{ command": { "action": "focus(Next|Prev)Pane", "order": "inOrder"|"mru", "useSwitcher": true|false } },

and order defaults to mru, and useSwitcher will default to true, when
there is a switcher. So

{ command": { "action": "focusNextPane" } },
{ command": { "action": "focusNextPane", "order": "mru" } },

these are the same action. (but right now we don't support the order
param)

Then there'll be another PR for "focusPane(target=id)"

Then a third PR for "focus(Next|Prev)Pane(order=inOrder)"

for the record, I prefer this approach over the "one action to rule
them all" version with both target and order/direction as params,
because I don't like the confusion of what happens if there's both
target and order/direction provided.

References #1000
Closes #2871

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few other things:

  • Don't forget to update the docs/schema
  • what happens if we provide "next" or "previous" to "resizePane"?

src/cascadia/TerminalApp/Pane.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsModel/defaults.json Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Pane.cpp Outdated Show resolved Hide resolved
@ghost ghost added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Nov 7, 2020
@PankajBhojwani
Copy link
Contributor Author

PankajBhojwani commented Nov 9, 2020

what happens if we provide "next" or "previous" to "resizePane"?

The _Resize() function will return false and nothing happens. I've noted in the docs that the direction given to resize cannot be next or previous. If people feel strongly about it we can make them two distinct direction enums?

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _Resize() function will return false and nothing happens. I've noted in the docs that the direction given to resize cannot be next or previous. If people feel strongly about it we can make them two distinct direction enums?

A few issues here:

  1. Generally, when you put an invalid value for the arg in the json, we display a warning.
  2. When you say "nothing happens" does it eat the keybinding or does the keybinding still get sent to the buffer (i.e. ^A)?
  3. Right now, we have enum mappers exposing enums to the Settings UI. Though keybindings aren't there yet, we'll probably use this the same way. If we have a single enum mapper for Direction, we'll have to figure out how to exclude "next" and "previous" in one keybinding arg, but not the other.

I'd rather you split the enum into 2 different ones in the schema and the code. It just acts more properly that way and it's more future-proof.

doc/cascadia/profiles.schema.json Outdated Show resolved Hide resolved
@ghost ghost added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Nov 9, 2020
@PankajBhojwani
Copy link
Contributor Author

I'd rather you split the enum into 2 different ones in the schema and the code. It just acts more properly that way and it's more future-proof.

Fair enough, its split now!

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. You could keep the ResizeDirection as just plain Direction if you wanted to reduce the diff. But I'm fine either way.

@zadjii-msft zadjii-msft self-assigned this Nov 10, 2020
@zadjii-msft
Copy link
Member

Okay my immediate thoughts are around how we expose this action to the user. We're already running into similar struggles with next/prevTab and the tab switcher, so maybe we should try and pre-empt those issues with pane switching?

For reference, there's also discussion in #8025 that might be helpful.

So, with next/prev MRU switching, without some sort of dialog, those will just toggle between the last two used panes. If there's a fourth pane, that pane will be inaccessible with next/prev pane.

Also, having panes in the ATS is something we might want some day, with something like:

  • Tab 1:
    • Pane 1: cmd.exe
    • Pane 2: pwsh.exe
  • Tab 2:
    • Pane 1: wsl.exe

whatever, you get it.

Plus, do we want to enable in-order next/prev traversal? Once we have pane IDs, then presumably, yea.


Do we want to overload moveFocus to accept next and prev, or would having another action entirely be better? Here are some proposals:

// Focus pane 1
// - This is sensible, no arguments here
{ command": { "action": "focusPane", "id": 1 } },

// Focus the next in order pane, don't use the switcher
// - We'd have to ensure that an id and order aren't passed at the same time, and that might be unintuitive
// - How do we specify next/prev? "direction" seems wrong, but maybe we keep the
//   FocusDirection(up|down|left|right|next|prev) enum and have one focus action 
//   to rule them all
{ command": { "action": "focusPane", "order": "inOrder", useSwitcher": false } },

// Focus the next MRU pane
// - Withough the switcher, this can only go one pane deep in the MRU stack
// - presumably once there's a pane switcher, it would default to enabled?
{ command": { "action": "focusNextPane", "order": "mru" } },

// Focus the prev inOrder pane
// - this seems straightforward
{ command": { "action": "focusPrevPane", "order": "inOrder" } },

// Focus the next pane, in mru order, explicitly disable the switcher
// - The user opted in to only being able to MRU switch one deep. That's fine, that's what they want.
{ command": { "action": "focusNextPane", "order": "mru", "useSwitcher": false} },

// Focus the prev inOrder pane, explicitly with the switcher
// - Maybe they disabled the switcher globally, but what it on for this action? 
{ command": { "action": "focusPrevPane", "order": "inOrder", "useSwitcher": true } },

Thoughts?

@zadjii-msft

This comment has been minimized.

@ghost

This comment has been minimized.

@zadjii-msft
Copy link
Member

@msftbot make sure @zadjii-msft signs off on this

@ghost ghost added the AutoMerge Marked for automatic merge by the bot when requirements are met label Nov 18, 2020
@ghost
Copy link

ghost commented Nov 18, 2020

Hello @zadjii-msft!

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'll only merge this pull request if it's approved by @zadjii-msft

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

@zadjii-msft zadjii-msft 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. Product-Terminal The new Windows Terminal. labels Nov 18, 2020
@PankajBhojwani
Copy link
Contributor Author

I like the idea of having separate commands for focusPrevPane and focusNextPane in preparation for the pane switcher.

Plus, do we want to enable in-order next/prev traversal? Once we have pane IDs, then presumably, yea.

I am not sure about this, we will need a way for the user to know the pane IDs and that may not always be feasible - paging @DHowett for thoughts on this

@carlos-zamora
Copy link
Member

Do we want to overload moveFocus to accept next and prev, or would having another action entirely be better? Here are some proposals:

@zadjii-msft @PankajBhojwani Could we create a spec for this and discuss the design in a brownbag? There seems to be a lot of options here. And I'd like to make sure the design interacts well with the current ATS customization model. Especially given our recent experience with ATS MRU.

@DHowett
Copy link
Member

DHowett commented Nov 19, 2020

I don’t think this requires a spec. An informal chat should do!

@cinnamon-msft
Copy link
Contributor

Is { command": { "action": "focusPrevPane", "order": "inOrder" } }, in order of creation or in order from left-right, top-bottom? Also does this order change once we get pane rearrangement?

@zadjii-msft zadjii-msft mentioned this pull request Nov 23, 2020
2 tasks
@ghost
Copy link

ghost commented Dec 4, 2020

Hello @zadjii-msft!

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 Fri, 04 Dec 2020 23:12:51 GMT, which is in 19 hours

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

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.

I think I follow all this, and it looks good to me. I'm telling the bot to wait until EOD Friday to merge this, to give Dustin one last chance, but I think this is fine

pair_type{ "left", ValueType::Left },
pair_type{ "right", ValueType::Right },
pair_type{ "up", ValueType::Up },
pair_type{ "down", ValueType::Down },
pair_type{ "previous", ValueType::Previous },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait did we want the setting to be previous or prev? It's prevTab and nextTab now,

But you know what I'm totally okay with this.

src/cascadia/TerminalApp/TerminalTab.cpp Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalTab.cpp Show resolved Hide resolved
@DHowett DHowett removed the AutoMerge Marked for automatic merge by the bot when requirements are met label Dec 4, 2020
@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Dec 5, 2020
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Dec 7, 2020
@zadjii-msft zadjii-msft removed their assignment Dec 8, 2020
@DHowett
Copy link
Member

DHowett commented Dec 10, 2020

Hit this with a code format!

@zadjii-msft zadjii-msft mentioned this pull request Dec 10, 2020
4 tasks
@DHowett DHowett added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Dec 10, 2020
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Dec 11, 2020
@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Dec 11, 2020
@ghost
Copy link

ghost commented Dec 11, 2020

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

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 (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 04309a2 into main Dec 11, 2020
@ghost ghost deleted the dev/pabhoj/mru_pane branch December 11, 2020 18:36
@zadjii-msft zadjii-msft mentioned this pull request Dec 15, 2020
8 tasks
zadjii-msft added a commit that referenced this pull request Jan 11, 2021
## Summary of the Pull Request

This is a spec for "pane navigation", as we've already got a bit of an implementation in #8183. We've also had a heated discussion in Teams, and I wanted to capture a bit of that in a more formal doc. I suppose that "informal Teams chat" didn't work out in the end 😆.

Also, this is @PankajBhojwani's feature so I'm gonna let him drive. I mostly wrote this to test out a new spec template.

After discussion, we landed on proposal D, with a minor change of `last` to `prev`. This is how it was in #8183 before I started meddling 😝 

## PR Checklist
* [x] spec for #2871
* [x] I work here

## Detailed Description of the Pull Request / Additional comments

This is not my best spec ever - again, mostly just trying to spawn discussion, and prototype the new spec template.
ghost pushed a commit that referenced this pull request Jan 11, 2021
## Summary of the Pull Request

Adds support for the `move-focus` subcommand to `wt.exe`. This subcommand works _exactly_ like `moveFocus(up|down|left|right)`. 

## References
* Will surely conflict with #8183
* Is goodness even in the world where #5464 exists

## PR Checklist
* [x] Closes #6580 
* [x] I work here
* [x] Tests added/passed
* [x] Docs PR: MicrosoftDocs/terminal#209

## Detailed Description of the Pull Request / Additional comments

Bear with me, I wrote this before paternity leave, so code might be a bit stale.

Oddly, after startup, this _does not_ leave the focus on the pane you moved to. If you `move-focus` during startup, at the end of startup, we'll still focus a _random_ pane. This is because the terminal still auto-focus a TermControl when it's done with layout. While we'll maintain the active control just fine during the startup, at the end of startup, all the controls will complete layout in a random order. 

This is no different than the startup right now. `wt sp ; sp ; sp` will focus a random pane at the end. This is left for a future someone to fix

This is also subject to #2398 / #4692. Moving in a direction isn't _totally_ reliable currently. `focus-pane -t ID` will certainly be more reliable, but this will work in the meantime?

## Validation Steps Performed

Opened probably 100 terminals, confirmed that the layout was always correct. Final focused pane was random, but the layout was right.
mpela81 pushed a commit to mpela81/terminal that referenced this pull request Jan 28, 2021
Adds a "move to previous pane" and "move to next pane" keybinding, which
navigates to the last/first focused pane

We assign pane IDs on creation and maintain a vector of active pane IDs
in MRU order. Navigating panes by MRU then requires specifying which
pane ID we want to focus. 

From our offline discussion (thanks @zadjii-msft for the concise
description):

> For the record, the full spec I'm imagining is:
> 
> { command": { "action": "focus(Next|Prev)Pane", "order": "inOrder"|"mru", "useSwitcher": true|false } },
> 
> and order defaults to mru, and useSwitcher will default to true, when
> there is a switcher. So 
> 
> { command": { "action": "focusNextPane" } },
> { command": { "action": "focusNextPane", "order": "mru" } },
> 
> these are the same action. (but right now we don't support the order
> param)
>  
> Then there'll be another PR for "focusPane(target=id)"
> 
> Then a third PR for "focus(Next|Prev)Pane(order=inOrder)"

> for the record, I prefer this approach over the "one action to rule
> them all" version with both target and order/direction as params,
> because I don't like the confusion of what happens if there's both
> target and order/direction provided. 

References microsoft#1000 
Closes microsoft#2871
mpela81 pushed a commit to mpela81/terminal that referenced this pull request Jan 28, 2021
## Summary of the Pull Request

This is a spec for "pane navigation", as we've already got a bit of an implementation in microsoft#8183. We've also had a heated discussion in Teams, and I wanted to capture a bit of that in a more formal doc. I suppose that "informal Teams chat" didn't work out in the end 😆.

Also, this is @PankajBhojwani's feature so I'm gonna let him drive. I mostly wrote this to test out a new spec template.

After discussion, we landed on proposal D, with a minor change of `last` to `prev`. This is how it was in microsoft#8183 before I started meddling 😝 

## PR Checklist
* [x] spec for microsoft#2871
* [x] I work here

## Detailed Description of the Pull Request / Additional comments

This is not my best spec ever - again, mostly just trying to spawn discussion, and prototype the new spec template.
mpela81 pushed a commit to mpela81/terminal that referenced this pull request Jan 28, 2021
## Summary of the Pull Request

Adds support for the `move-focus` subcommand to `wt.exe`. This subcommand works _exactly_ like `moveFocus(up|down|left|right)`. 

## References
* Will surely conflict with microsoft#8183
* Is goodness even in the world where microsoft#5464 exists

## PR Checklist
* [x] Closes microsoft#6580 
* [x] I work here
* [x] Tests added/passed
* [x] Docs PR: MicrosoftDocs/terminal#209

## Detailed Description of the Pull Request / Additional comments

Bear with me, I wrote this before paternity leave, so code might be a bit stale.

Oddly, after startup, this _does not_ leave the focus on the pane you moved to. If you `move-focus` during startup, at the end of startup, we'll still focus a _random_ pane. This is because the terminal still auto-focus a TermControl when it's done with layout. While we'll maintain the active control just fine during the startup, at the end of startup, all the controls will complete layout in a random order. 

This is no different than the startup right now. `wt sp ; sp ; sp` will focus a random pane at the end. This is left for a future someone to fix

This is also subject to microsoft#2398 / microsoft#4692. Moving in a direction isn't _totally_ reliable currently. `focus-pane -t ID` will certainly be more reliable, but this will work in the meantime?

## Validation Steps Performed

Opened probably 100 terminals, confirmed that the layout was always correct. Final focused pane was random, but the layout was right.
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. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Add nextPane and prevPane keybindings
5 participants