Skip to content

Fix: Prevent Enter key leaking to terminal during Command Palette actions#20221

Open
nicolasalarconrapela wants to merge 1 commit into
microsoft:mainfrom
nicolasalarconrapela:fix/command-palette-enter-leak
Open

Fix: Prevent Enter key leaking to terminal during Command Palette actions#20221
nicolasalarconrapela wants to merge 1 commit into
microsoft:mainfrom
nicolasalarconrapela:fix/command-palette-enter-leak

Conversation

@nicolasalarconrapela
Copy link
Copy Markdown

@nicolasalarconrapela nicolasalarconrapela commented May 13, 2026

Summary of the Pull Request

This PR addresses the issue reported in #20188, where triggering the "Export Text" action from the Command Palette would result in a phantom Enter key press being sent to the active terminal session.

The original implementation marked the event as handled (args.Handled(true)) only after invoking the _ExportTab function. When no predefined file path is provided (the default behavior in the Command Palette), _ExportTab triggers a modal Windows dialog (FileSavePicker). This system dialog captures the UI focus immediately.

The Problem

Because the focus shifted before the event was marked as handled, the WinUI event routing system allowed the residual Enter keystroke to "leak" into the terminal control that regained focus in the background.

This behavior might stem from an early design focus on single-window control architectures, as seen in previous discussions like: #6635

Solution

  1. Early Neutralization: Moved args.Handled(true); to the very beginning of the _HandleExportBuffer method. This ensures the Enter event is consumed by the Command Palette while it still holds focus, preventing any further propagation.

  2. Flow Refactoring: Refactored the method to utilize a single execution path for _ExportTab. The method now prepares the path string and executes the call once, improving code readability and ensuring consistent behavior regardless of whether a path argument is provided.

Validation Steps Performed

Before

before

After

after

PR Checklist

@nicolasalarconrapela
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@nicolasalarconrapela nicolasalarconrapela marked this pull request as ready for review May 14, 2026 10:32
@nicolasalarconrapela nicolasalarconrapela changed the title Fix: Prevent Enter key leaking to terminal during Command Palette actions (#20188) Fix: Prevent Enter key leaking to terminal during Command Palette actions May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Export text" action invoked from cmd paletter forwards Enter key

1 participant