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

If you rename the tab and then click on Export Text, the filename is the previous title of the tab #13909

Closed
MontecaE opened this issue Sep 2, 2022 · 3 comments · Fixed by #13915
Labels
Area-UserInterface Issues pertaining to the user interface of the Console or Terminal good first issue This is a fix that might be easier for someone to do as a first contribution Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-3 A description (P3) Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Milestone

Comments

@MontecaE
Copy link

MontecaE commented Sep 2, 2022

Windows Terminal version

1.14.2281.0

Windows build number

10.0.19044.0

Other Software

No response

Steps to reproduce

Title of a tab is Administrator: PowerShell

  • rename it to asd
  • click on Export Text
  • (default) filename is Administrator: PowerShell.txt

Expected Behavior

The (default) filename exported is the tab name (so, in this example asd.txt)

Actual Behavior

The filename is not aligned to the tab title

@MontecaE MontecaE added the Issue-Bug It either shouldn't be doing this or needs an investigation. label Sep 2, 2022
@ghost ghost added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Sep 2, 2022
@zadjii-msft
Copy link
Member

Should be easy enough to fix:

winrt::fire_and_forget TerminalPage::_ExportTab(const TerminalTab& tab, winrt::hstring filepath)
{
// This will be used to set up the file picker "filter", to select .txt
// files by default.
static constexpr COMDLG_FILTERSPEC supportedFileTypes[] = {
{ L"Text Files (*.txt)", L"*.txt" },
{ L"All Files (*.*)", L"*.*" }
};
// An arbitrary GUID to associate with all instances of this
// dialog, so they all re-open in the same path as they were
// open before:
static constexpr winrt::guid clientGuidExportFile{ 0xF6AF20BB, 0x0800, 0x48E6, { 0xB0, 0x17, 0xA1, 0x4C, 0xD8, 0x73, 0xDD, 0x58 } };
try
{
if (const auto control{ tab.GetActiveTerminalControl() })
{
auto path = filepath;
if (path.empty())
{
// GH#11356 - we can't use the UWP apis for writing the file,
// because they don't work elevated (shocker) So just use the
// shell32 file picker manually.
path = co_await SaveFilePicker(*_hostingHwnd, [control](auto&& dialog) {
THROW_IF_FAILED(dialog->SetClientGuid(clientGuidExportFile));
try
{
// Default to the Downloads folder
auto folderShellItem{ winrt::capture<IShellItem>(&SHGetKnownFolderItem, FOLDERID_Downloads, KF_FLAG_DEFAULT, nullptr) };
dialog->SetDefaultFolder(folderShellItem.get());
}
CATCH_LOG(); // non-fatal
THROW_IF_FAILED(dialog->SetFileTypes(ARRAYSIZE(supportedFileTypes), supportedFileTypes));
THROW_IF_FAILED(dialog->SetFileTypeIndex(1)); // the array is 1-indexed
THROW_IF_FAILED(dialog->SetDefaultExtension(L"txt"));
// Default to using the tab title as the file name
std::wstring filename{ control.Title() };
filename = til::clean_filename(filename);
THROW_IF_FAILED(dialog->SetFileName((filename + L".txt").c_str()));

Just use the tab's Title, rather than the control's Title, on line 437.

@zadjii-msft zadjii-msft added Help Wanted We encourage anyone to jump in on these. Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Product-Terminal The new Windows Terminal. Priority-3 A description (P3) good first issue This is a fix that might be easier for someone to do as a first contribution labels Sep 2, 2022
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Sep 2, 2022
@zadjii-msft zadjii-msft added this to the Backlog milestone Sep 2, 2022
@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 2, 2022
@ghost ghost closed this as completed in #13915 Sep 7, 2022
ghost pushed a commit that referenced this issue Sep 7, 2022
Takes title from the tab instead of the TermControl

Closes #13909
@ghost ghost added the Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. label Sep 7, 2022
DHowett pushed a commit that referenced this issue Sep 9, 2022
Takes title from the tab instead of the TermControl

Closes #13909

(cherry picked from commit 2c341c8)
Service-Card-Id: 85427880
Service-Version: 1.15
@ghost
Copy link

ghost commented Sep 13, 2022

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

Handy links:

@ghost
Copy link

ghost commented Sep 13, 2022

🎉This issue was addressed in #13915, which has now been successfully released as Windows Terminal Preview v1.16.252.: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 good first issue This is a fix that might be easier for someone to do as a first contribution Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-3 A description (P3) 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.

2 participants