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

[Setting] New tab button should open another of the currently selected tab #445

Open
Tracked by #6685
matthew4850 opened this issue May 6, 2019 · 13 comments
Open
Tracked by #6685
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal Help Wanted We encourage anyone to jump in on these. Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Milestone

Comments

@matthew4850
Copy link
Contributor

  • Your Windows build number: 10.0.18890.1000

  • What you're doing and what's happening: When you press the add tab button it always opens cmd.

  • What's wrong / what should be happening instead: It should open another of the currently viewed tab.

@zadjii-msft
Copy link
Member

It actually opens a new tab of whatever the defaultProfile is, which is the cmd profile by default currently.

We can add a setting that new tab opens a new instance of the active tab instead.

@zadjii-msft zadjii-msft added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label May 7, 2019
@zadjii-msft zadjii-msft added this to the Windows Terminal v1.0 milestone May 7, 2019
@zadjii-msft zadjii-msft changed the title New tab button should open another of the currently selected tab [Setting] New tab button should open another of the currently selected tab May 7, 2019
@HBelusca

This comment was marked as off-topic.

@zadjii-msft

This comment was marked as off-topic.

@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label May 17, 2019
@miniksa miniksa added Area-User Interface Issues pertaining to the user interface of the Console or Terminal Product-Terminal The new Windows Terminal. and removed Mass-Chaos labels May 17, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label May 18, 2019
@zadjii-msft zadjii-msft added Issue-Task It's a feature request, but it doesn't really need a major design. and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. labels Jun 20, 2019
@zadjii-msft
Copy link
Member

I discussed this briefly with @DHowett-MSFT today. On the surface, this seems a bit like #1536, which was implemented in #1685. However, this actually has to do with specifically the behavior of the new tab button, not just the keybinding. I'm leaving this open to track changing the behavior of the new tab button.

@haolly
Copy link

haolly commented Nov 10, 2019

As a end user, I understand "dumplicate current tab" means the new tab will be in the same directory as the source, but #1685 does not.
Seems like #1685 is just bind a shortcut to the plus + button's functionality

@zadjii-msft
Copy link
Member

Moving relevant discussion from #11337

Description of the new feature/enhancement

Currently the new tab button opens a terminal the default profile. So for example, with my default set to WSL: Debian, the new tab button will always open with that profile.

Instead I think it'd be nice to have the new tab button open a terminal using the same profile as the currently active tab. This way if I have a non-default profile open, such as PowerShell, the + button would open a new PowerShell tab instead.

Proposed technical implementation details

The default profile could have an additional setting called Currently Active. When a new tab is opened you'd need a way to retrieve the profile of the currently active tab, then open the new tab using that profile.

You know, I might be wrong about that. I had this in my list of "issues to post in the future"

Add a setting to default the new tab button to "duplicate tab" instead of "open default profile"

Maybe that applies to the splitPane actions as well?
Is this just asking for "toolbar customization" though? Should this be an extension? How would we let an extension do that?
Would they get at the tab row, hide the new tab button, then add their own split button, with the same new tab menu, but with duplicateTab bound instead?

Crazy shower thought:

"newTabButton": {
  "action": { /* duplicate tab*/ },
  "icon": "whatever",
  "showDropdown": false
}

Also related: #6685

I tinkered on this a bit out of curiosity and it turned out to be pretty easy to implement: PathogenDavid@67a370e

diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp
index 752e8e590..96b80f16a 100644
--- a/src/cascadia/TerminalApp/TerminalPage.cpp
+++ b/src/cascadia/TerminalApp/TerminalPage.cpp
@@ -214,5 +214,13 @@ namespace winrt::TerminalApp::implementation
             if (auto page{ weakThis.get() })
             {
-                page->_OpenNewTerminal(NewTerminalArgs());
+                // Duplicate the focused terminal if there is one, otherwise create one from the default profile
+                if (const auto focusedTab{ page->_GetFocusedTabImpl() })
+                {
+                    page->_DuplicateTab(*focusedTab);
+                }
+                else
+                {
+                    page->_OpenNewTerminal(NewTerminalArgs());
+                }
             }
         });

(Unfortunately I'm not very confident I'll have any time soon to formalize it enough to make it a proper contribution, but maybe I'll save someone else a bit of time investigating.)

Edit: Worth noting that this doesn't handle the keyboard shortcuts, just clicking the button. Ctrl+Shift+T comes in in TerminalPage::_HandleNewTab and it already has NewTerminalArgs originating somewhere in the keyboard shortcut event handling schmoo, might look into that more later too.

@zadjii-msft zadjii-msft added Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Help Wanted We encourage anyone to jump in on these. and removed Issue-Task It's a feature request, but it doesn't really need a major design. labels Jul 8, 2022
@zadjii-msft
Copy link
Member

zadjii-msft commented Jul 8, 2022

pseudo-spec in progress:

scenarios

proposal

"newTabButton": {
  "command": { /* duplicate tab */ },
  "icon": "whatever",
  "showDropdown": false
}

So, to revisit each scenario

  • "command": "duplicateTab"
  • "command": { "action": "newTab", "startingDirectory": "." } should work
  • Maybe "icon": null is a sensible way to hide the + side of the button?
  • "showDropdown":false seems to be a sensible way to hide the dropdown.
  • E may best be supported by an addenda to Allow dropdown menu customization in profiles.json #1571, and I really don't think we need here. There's a wide gulf between getting the list of open Terminal windows plumbed into the actual XAML layer.

Y'all could be crazy people and have like,

"newTabButton": {
  "command": "toggleCommandPalette",
  "icon": "\uE945",
  "showDropdown": true
}

Cause, why not?


feb 2024 updates:

  • newTabButton could absolutely just be an array of entries. Each either turns into a button or a dropdown button.
  • We should absolutely just use action IDs from Add a global mechanism for refering to actions #6899
  • The default action ID will just be the Microsoft.Terminal.NewTab ID, and the user can trivially change that by changing the action ID to duplicateTab.
  • it should just be menu: menu: true|false|[NewTabMenuEntry]
"newTabButton": [
  {
    "command": "Microsoft.Terminal.NewTab",
    "icon": "+",
    "menu": true
  },
  {
    "command": "Microsoft.Terminal.CommandPalette",
    "icon": "\uE945",
    "menu": false
  }
]

and that gets us #2934 too.

@vertigo220
Copy link

Another possibility in addition to this would be the ability to set left-/middle-/right-click options, so e.g. left-clicking the new tab button could open a cmd terminal, right-clicking could open a PS terminal, and middle-clicking a different one, all customizable in settings, of course. And if this were done, what each click does should be shown in the button's tooltip. It could even be further enhanced by opening the new tab either in the CWD or the default one depending on whether a modifier, most likely Ctrl, is used.

@marcelwgn
Copy link
Contributor

What would be the best way moving forward for this feature?

@zadjii-msft
Copy link
Member

@chingucoding Sorry I missed that comment at the start of the year. Next steps here are basically:

  • have me flush out the above comment
  • Discuss with the team some (we'll next have quorum next week probably). I'll probably move for a vote of unanimous consent - it's not a terribly complicated proposal and I think it covers the problem space
  • If there aren't any NAKs then I'll probably turn that into a walkthrough similar to what I did with Allow dropdown menu customization in profiles.json #1571. I honestly think the settings aren't all that bad so wiring this up shouldn't be that hard...

@zadjii-msft zadjii-msft added the Needs-Discussion Something that requires a team discussion before we can proceed label May 2, 2023
@zadjii-msft
Copy link
Member

Dustin: "As long as I go into the settings and hit save and a newTabButton object doesn't appear, I'm cool with it"

We talked for a while about

  • does that design enable us to do everything we want?
  • does that design preclude us from doing something crazy in the future?

and we were fairly confident that it was good enough. Maybe there should have been some overlap between newTabMenu and newTabButton. Maybe showDropdown should have just been menu, where we stick the newTabMenu json.

The only real sticking point: We can probably get rid of icon, and use the icon of the command itself. If there's no icon on the command, then remove the button.....
But I actually don't love that, because the newTab action doesn't just come with an icon.

Alright so next steps: I need to write a walkthrough

@zadjii-msft zadjii-msft removed the Needs-Discussion Something that requires a team discussion before we can proceed label May 10, 2023
@github-project-automation github-project-automation bot moved this to Should be written in Terminal Walkthroughs May 10, 2023
@zadjii-msft
Copy link
Member

wow TIL: https://mastodon.social/@JenMsft/111528828382278248

What's a feature you use a lot on your PC that you think other people probably don't know about?

I'll start - middle click on the refresh button in the browser to duplicate the current tab

It's absolutely the least discoverable feature I've ever seen, but I'm 100% here for "middle-click the new tab button duplicates"

@PathogenDavid
Copy link

On one hand I'd probably just prefer duplicate-by-default, but on the other hand I'm a frequent user of the middle-click-refresh gesture so I could certainly get used to doing that in Windows Terminal as well.

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 Help Wanted We encourage anyone to jump in on these. Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Projects
Status: Should be written
Development

No branches or pull requests