Repository: microsoft/terminal (language: cpp)

Issue:
If you rename the tab and then click on Export Text, the filename is the previous title of the tab
### 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


Discussion / hints:
Should be easy enough to fix:
https://github.com/microsoft/terminal/blob/fe0d57071edee4ceb650990d3acd2838fec2ee7f/src/cascadia/TerminalApp/TabManagement.cpp#L399-L439

Just use the `tab`'s Title, rather than the `control`'s Title, on line 437.

Fix patch:
diff --git a/src/cascadia/TerminalApp/TabManagement.cpp b/src/cascadia/TerminalApp/TabManagement.cpp
index 80de157e251..ab9a6a318d6 100644
--- a/src/cascadia/TerminalApp/TabManagement.cpp
+++ b/src/cascadia/TerminalApp/TabManagement.cpp
@@ -420,7 +420,9 @@ namespace winrt::TerminalApp::implementation
                     // 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) {
+                    std::wstring filename{ tab.Title() };
+                    filename = til::clean_filename(filename);
+                    path = co_await SaveFilePicker(*_hostingHwnd, [filename = std::move(filename)](auto&& dialog) {
                         THROW_IF_FAILED(dialog->SetClientGuid(clientGuidExportFile));
                         try
                         {
@@ -434,8 +436,6 @@ namespace winrt::TerminalApp::implementation
                         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()));
                     });
                 }


Test patch: