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

Selected tab title not used for Export Text file name #13948

Closed
elsaco opened this issue Sep 8, 2022 · 9 comments · Fixed by #14673
Closed

Selected tab title not used for Export Text file name #13948

elsaco opened this issue Sep 8, 2022 · 9 comments · Fixed by #14673
Labels
Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.

Comments

@elsaco
Copy link

elsaco commented Sep 8, 2022

Windows Terminal version

main 1ef4a42

Windows build number

10.0.19044.0

Other Software

No response

Steps to reproduce

  • build WT with Use the tab's active title for "Export Text" patch applied, commit 2c341c8
  • rename some tabs
  • export text from a tab other than active one

Foo was the active tab and Bar was used for export:
wt_export_text

Expected Behavior

  • tab's title used for filename

Actual Behavior

  • the active's tab title is being used instead
@elsaco elsaco added the Issue-Bug It either shouldn't be doing this or needs an investigation. label Sep 8, 2022
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Sep 8, 2022
@DHowett
Copy link
Member

DHowett commented Sep 8, 2022

It's much worse than that: it actually only exports the active tab. It can't export a non-active tab.

How? It takes tab in as an action argument...! Did we mess something up this egregiously?

@ianjoneill
Copy link
Contributor

So this and #13942 are somewhat related.

Of the tab related context menu items "Duplicate Tab", "Split Tab", "Export Text" and "Find", the only one that does what you expect on an unfocused tab is "Split Tab".

The callbacks are all set up in TabManagement.cpp:

newTabImpl->DuplicateRequested([weakTab, weakThis{ get_weak() }]() {
auto page{ weakThis.get() };
auto tab{ weakTab.get() };
if (page && tab)
{
page->_DuplicateTab(*tab);
}
});
newTabImpl->SplitTabRequested([weakTab, weakThis{ get_weak() }]() {
auto page{ weakThis.get() };
auto tab{ weakTab.get() };
if (page && tab)
{
page->_SplitTab(*tab);
}
});
newTabImpl->ExportTabRequested([weakTab, weakThis{ get_weak() }]() {
auto page{ weakThis.get() };
auto tab{ weakTab.get() };
if (page && tab)
{
// Passing null args to the ExportBuffer handler will default it
// to prompting for the path
page->_HandleExportBuffer(nullptr, nullptr);
}
});
newTabImpl->FindRequested([weakTab, weakThis{ get_weak() }]() {
auto page{ weakThis.get() };
auto tab{ weakTab.get() };
if (page && tab)
{
page->_Find();
}
});

They delegate to:

  • TerminalPage::_DuplicateTab(): duplicates the currently focused tab
  • TerminalPage::_SplitTab(): works as expected, as it focuses the selected tab and then splits it
  • TerminalPage::_HandleExportBuffer(): exports the currently focused tab's content
  • TerminalPage::_Find(): searches the currently focused tab's control

I guess the quick win would be to replicate what SplitTab() does - i.e. focus the selected tab and then do the duplicate/export/find. Is that reasonable?

@zadjii-msft
Copy link
Member

That seems like a reasonable solution to me. Think that'll knock out all of this issue, #13942 and #13579 all in one go?

@zadjii-msft zadjii-msft added Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Product-Terminal The new Windows Terminal. labels Sep 9, 2022
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Sep 9, 2022
@zadjii-msft zadjii-msft added Help Wanted We encourage anyone to jump in on these. Needs-Tag-Fix Doesn't match tag requirements labels Sep 9, 2022
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Sep 9, 2022
@zadjii-msft zadjii-msft added this to the Terminal v1.17 milestone Sep 9, 2022
@ianjoneill
Copy link
Contributor

Hmm doesn't look like it's that straight forward - _SetFocusedTab() is async. As @JerBast suggests - _DuplicateTab() and _SplitTab() delegate to _MakePane(), which won't necessarily get the focused tab due it's async nature.

@DHowett
Copy link
Member

DHowett commented Sep 9, 2022

Generally speaking, I'd rather us fix the event plumbing so that things that come out of (1) the pane, (2) the tab and (3) the terminal control are tagged up appropriately so we know their origination chain. Is that something doable on a reasonable time horizon?

@serd2011
Copy link
Contributor

serd2011 commented Sep 9, 2022

maybe _MakePane(newTerminalArgs, bool duplicate, existingConnection) should accept something like const TerminalTab& sourceTab instead of bool duplicate?
That way _DuplicateTab will pass the tab to _MakePane and it should work.

@JerBast
Copy link
Contributor

JerBast commented Sep 9, 2022

Changing _MakePane would work for #13942 for sure. For this issue, it is also possible to replace the call to pane->_HandleExportBuffer(...) with a call to pane->_ExportTab(*tab, L"") directly.

@ianjoneill
Copy link
Contributor

I'd come to the same conclusions. There's no point 3 people working on it though, so I'll leave it to you 🙂

@zadjii-msft zadjii-msft removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Sep 15, 2022
@ghost ghost added the In-PR This issue has a related PR label Jan 13, 2023
@ghost ghost closed this as completed in #14673 Jan 16, 2023
@ghost ghost added Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed In-PR This issue has a related PR labels Jan 16, 2023
ghost pushed a commit that referenced this issue Jan 16, 2023
…#14673)

## Summary of the Pull Request
Updates the tab event handling so that the "Export Text" and "Find" tab context menu items work when a tab isn't focused.

## PR Checklist
* [x] Closes #13948
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) 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

## Validation Steps Performed
Manually tested.
@ghost
Copy link

ghost commented Jan 24, 2023

🎉This issue was addressed in #14673, which has now been successfully released as Windows Terminal Preview v1.17.1023.:tada:

Handy links:

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants