Repository: microsoft/terminal (language: cpp)

Issue:
Reset title sequences have stopped working in Windows Termial
### Windows Terminal version

Commit f93347ed4bbeea0d9e663f2069994d9e2d069f10

### Windows build number

10.0.19045.4780

### Other Software

_No response_

### Steps to reproduce

1. Open a WSL bash shell in a recent build of Windows Terminal (I suspect it needs to be 450eec48de252a3a8d270bade847755ecbeb5a75 or later).
2. Make sure your shell isn't configured to set the title itself.
3. Set the title with an OSC 0 sequence: `printf "\e]0;Test\e\\"`
4. Note that the title has changed.
5. Reset the title with a blank OSC 0 sequence: `printf "\e]0\e\\"`

### Expected Behavior

The title should be reset to its starting value. This works correctly in Terminal Preview and also in current builds of OpenConsole.

### Actual Behavior

The title is just set to a blank value. The same problem occurs with the `DECSWT` title sequence too.


Discussion / hints:
We've found some similar issues:


- #16784 , similarity score: 83%
  

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

> Note: You can give me feedback by 👍 or 👎 this comment.
Nice find Mr Bot, but I fixed that issue, and now it's regressed again.

Fix patch:
diff --git a/src/cascadia/TerminalCore/TerminalApi.cpp b/src/cascadia/TerminalCore/TerminalApi.cpp
index 9f51aadf00d..ffd9ec72af0 100644
--- a/src/cascadia/TerminalCore/TerminalApi.cpp
+++ b/src/cascadia/TerminalCore/TerminalApi.cpp
@@ -86,7 +86,7 @@ void Terminal::SetWindowTitle(const std::wstring_view title)
     _assertLocked();
     if (!_suppressApplicationTitle)
     {
-        _title.emplace(title);
+        _title.emplace(title.empty() ? _startingTitle : title);
         _pfnTitleChanged(_title.value());
     }
 }


Test patch: