mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 09:46:54 +02:00
## Summary Closes #39929 Adds a new "Keep previous query" toggle to Command Palette settings that preserves the last search text when the palette is reopened after running a command. ## Changes - **`SettingsModel.cs`** — Added `KeepPreviousQuery` bool property (defaults to `false`) - **`SettingsViewModel.cs`** — Added property with auto-save on change - **`GeneralPage.xaml`** — Added toggle switch in the Activation section, below "Highlight search on activate" - **`Resources.resw`** — Added localized header ("Keep previous query") and description ("Preserves the last search text when Command Palette is reopened") - **`SearchBar.xaml.cs`** — `Receive(GoHomeMessage)` now checks the setting and skips `ClearSearch()` when enabled ## Behavior - **Off (default):** No change from current behavior — search text is cleared on dismiss. - **On:** When a command is run and the palette dismisses, the search text is preserved. On reopen, the previous query is still in the search box. Combined with the existing "Highlight search on activate" setting, the text will be pre-selected so the user can immediately retype or press Enter to re-run. ## Validation - Setting off: search clears on dismiss (existing behavior unchanged) - Setting on: search text persists across dismiss/reopen - Setting serializes/deserializes correctly via existing JSON settings infrastructure - No impact on page navigation, escape key behavior, or auto-go-home timer --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>