Add --position argument to wt new-tab command#20082
Add --position argument to wt new-tab command#20082Jotanune wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Adds a --position argument to the wt new-tab subcommand, allowing users to control where new tabs are inserted without changing the global newTabPosition setting. - Add Position property (IReference<NewTabPosition>) to NewTabArgs - Move NewTabPosition enum from GlobalAppSettings.idl to ActionArgs.idl to avoid circular IDL imports - Register --position CLI option in _buildNewTabParser() accepting afterCurrentTab and afterLastTab - Calculate insert position in _HandleNewTab and pass through _OpenNewTab to _CreateNewTabFromPane - Add JSON schema support for the position property in NewTabAction - Add CmdTabPositionArgDesc localization resource string - Add ParseNewTabWithPosition test covering all cases Closes microsoft#14687
@microsoft-github-policy-service agree |
| { | ||
| if (position.Value() == NewTabPosition::AfterCurrentTab) | ||
| { | ||
| auto currentTabIndex = _GetFocusedTabIndex(); |
There was a problem hiding this comment.
Does this get the index of the tab in which the wt command was run? From the function name, I'd assume it doesn't.
There was a problem hiding this comment.
You are absolutely right. _GetFocusedTabIndex() grabs the currently active tab, which completely fails the sleep 10 edge-case if the user switches tabs during execution. I'll look into the proper way to resolve the origin tab and update the PR.
There was a problem hiding this comment.
I'm gonna tell you it's not possible in the general case to do so. :)
There was a problem hiding this comment.
Haha, thanks for the reality check @DHowett that definitely saves me from going down an impossible rabbit hole with WT_SESSION and IPC messages. 😅
Given that tracking the exact originating tab asynchronously isn't technically feasible in the general architecture, would using the currently focused tab (as currently implemented via _GetFocusedTabIndex()) be an acceptable compromise for this feature? It solves the immediate UX need for synchronous commands like your vspwsh alias mentioned in the issue, even if it falls short on the sleep 10 edge-case.
Let me know if you guys are happy with this trade-off, or if I should add a specific comment in the code/docs about this limitation.
Summary of the Pull Request
Adds a
--positionargument to thewt new-tabsubcommand, allowing users to control where new tabs are inserted without changing the globalnewTabPositionsetting.This addresses #14687.
References and Relevant Issues
Closes #14687
Detailed Description of the Pull Request / Additional comments
Changes:
Positionproperty (IReference<NewTabPosition>) toNewTabArgs, with full JSON serialization, equality, copy, and hash support.NewTabPositionenum fromGlobalAppSettings.idltoActionArgs.idlto avoid circular IDL import dependencies. The enum remains accessible toGlobalAppSettingsthrough the transitive import chain.--positionCLI option in_buildNewTabParser(), acceptingafterCurrentTabandafterLastTabstring values._HandleNewTabto extract the position fromNewTabArgs, calculate the insert index, and pass it to_OpenNewTab._OpenNewTabsignature to accept aninsertPositionparameter, forwarded to_CreateNewTabFromPane.CmdTabPositionArgDesclocalization resource string.positionproperty toNewTabActionschema.ParseNewTabWithPositiontest method with 4 test cases.Usage:
Validation Steps Performed
ParseNewTabWithPositionadded with 4 test cases