mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
CmdPal: entirely redo the Run page (#39955)
This entirely rewrites the shell page. It feels a lot more like the old run dialog now. * It's got icons for files & exes * it can handle network paths * it can handle `commands /with args...` * it'll suggest files in that path as you type * it handles `%environmentVariables%` * it handles `"Paths with\spaces in them"` * it shows you the path as a suggestion, in the text box, as you move the selection References: Closes #39044 Closes #39419 Closes #38298 Closes #40311 ### Remaining todo's * [x] Remove the `GenerateAppxManifest` change, and file something to fix that. We are still generating msix's on every build, wtf * [x] Clean-up code * [x] Double-check loc * [x] Remove a bunch of debug printing that we don't need anymore * [ ] File a separate PR for moving the file (indexer) commands into a common project, and re-use those here * [x] Add history support again! I totally tore that out * did that in #40427 * [x] make `shell:` paths and weird URI's just work. Good test is `x-cmdpal://settings` ### further optimizations that probably aren't blocking * [x] Our fast up-to-date is clearly broken, but I think that's been broken since early 0.91 * [x] If the exe doesn't change, we don't need to create a new ListItem for it. We can just re-use the current one, and just change the args * [ ] if the directory hasn't changed, but we typed more chars (e.g. `c:\windows\s` -> `c:\windows\sys`), we should cache the ListItem's from the first query, and re-use them if possible.
This commit is contained in:
@@ -23,6 +23,8 @@ internal sealed partial class FallbackOpenFileItem : FallbackCommandItem, System
|
||||
|
||||
private uint _queryCookie = 10;
|
||||
|
||||
private Func<string, bool> _suppressCallback;
|
||||
|
||||
public FallbackOpenFileItem()
|
||||
: base(_baseCommandWithId, Resources.Indexer_Find_Path_fallback_display_title)
|
||||
{
|
||||
@@ -44,6 +46,17 @@ internal sealed partial class FallbackOpenFileItem : FallbackCommandItem, System
|
||||
return;
|
||||
}
|
||||
|
||||
if (_suppressCallback != null && _suppressCallback(query))
|
||||
{
|
||||
Command = new NoOpCommand();
|
||||
Title = string.Empty;
|
||||
Subtitle = string.Empty;
|
||||
Icon = null;
|
||||
MoreCommands = null;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (Path.Exists(query))
|
||||
{
|
||||
// Exit 1: The query is a direct path to a file. Great! Return it.
|
||||
@@ -128,4 +141,9 @@ internal sealed partial class FallbackOpenFileItem : FallbackCommandItem, System
|
||||
_searchEngine.Dispose();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public void SuppressFallbackWhen(Func<string, bool> callback)
|
||||
{
|
||||
_suppressCallback = callback;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Microsoft.CmdPal.Ext.Indexer.Data;
|
||||
using Microsoft.CmdPal.Ext.Indexer.Properties;
|
||||
using Microsoft.CommandPalette.Extensions;
|
||||
@@ -41,4 +42,9 @@ public partial class IndexerCommandsProvider : CommandProvider
|
||||
[
|
||||
_fallbackFileItem
|
||||
];
|
||||
|
||||
public void SuppressFallbackWhen(Func<string, bool> callback)
|
||||
{
|
||||
_fallbackFileItem.SuppressFallbackWhen(callback);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user