From 0b3dc089ac2af8062429ec6a3ebac9133be4ee0d Mon Sep 17 00:00:00 2001 From: Gordon Lam <73506701+yeelam-gordon@users.noreply.github.com> Date: Mon, 26 Jan 2026 15:20:07 +0800 Subject: [PATCH] [Peek] Fix Space key triggering during file rename (#44845) (#44995) Don't show error window when CurrentItem is null - just return silently. This restores the original behavior where CaretVisible() detection in GetSelectedItems() would suppress Peek by returning null, and no window would be shown. PR #44703 added an error window for virtual folders (Home/Recent), but this also triggered when user was typing (rename, search, address bar), stealing focus and cancelling the operation. Fixes #44845 ## Summary of the Pull Request --- src/modules/peek/Peek.UI/PeekXAML/MainWindow.xaml.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/modules/peek/Peek.UI/PeekXAML/MainWindow.xaml.cs b/src/modules/peek/Peek.UI/PeekXAML/MainWindow.xaml.cs index 6e257cd73b..15c7812148 100644 --- a/src/modules/peek/Peek.UI/PeekXAML/MainWindow.xaml.cs +++ b/src/modules/peek/Peek.UI/PeekXAML/MainWindow.xaml.cs @@ -197,16 +197,10 @@ namespace Peek.UI ViewModel.Initialize(selectedItem); - // If no files were found (e.g., in virtual folders like Home/Recent), show an error + // If no files were found (e.g., user is typing in rename/search box, or in virtual folders), + // don't show anything - just return silently to avoid stealing focus if (ViewModel.CurrentItem == null) { - Logger.LogInfo("Peek: No files found to preview, showing error."); - var errorMessage = ResourceLoaderInstance.ResourceLoader.GetString("NoFilesSelected"); - ViewModel.ShowError(errorMessage); - - // Still show the window so user can see the warning - this.Show(); - WindowHelpers.BringToForeground(this.GetWindowHandle()); return; }