Fix Export Tab leaking Enter via Command Palette by carlos-zamora · Pull Request #20358 · microsoft/terminal
Summary of the Pull Request
Fixes a bug where Enter would leak into the terminal session when running the export buffer command from the command palette.
Turns out this is because _ExportTab() opens the file picker synchronously in the key handler. The file picker spins a nested Win32 modal message loop, which pumps the queued WM_CHAR into the terminal.
Switching to the foreground thread gets out of the nested modal loop, resulting in the WM_CHAR being handled through XAML's pipeline and suppressing it normally. The low priority makes it so that the command palette is visibly dismissed before opening the file picker.
Validation Steps Performed
Run export buffer action from the command palette.
✅ Enter does not go through to the underlying terminal.