Skip to content

Commit

Permalink
[PTRun]Fix always hiding even when an action fails (#21259)
Browse files Browse the repository at this point in the history
Hide PowerToys Run if the result action returns true, otherwise keep it open
  • Loading branch information
hlaueriksson committed Oct 25, 2022
1 parent 778bb7a commit aa6910a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/modules/launcher/PowerLauncher/ViewModel/MainViewModel.cs
Expand Up @@ -192,16 +192,21 @@ private void OpenResultsEvent(object index, bool isMouseClick)
// SelectedItem returns null if selection is empty.
if (result != null && result.Action != null)
{
Hide();
bool hideWindow = true;

Application.Current.Dispatcher.Invoke(() =>
{
result.Action(new ActionContext
hideWindow = result.Action(new ActionContext
{
SpecialKeyState = KeyboardHelper.CheckModifiers(),
});
});

if (hideWindow)
{
Hide();
}

if (SelectedIsFromQueryResults())
{
_userSelectedRecord.Add(result);
Expand Down
3 changes: 2 additions & 1 deletion src/modules/launcher/Wox.Plugin/Result.cs
Expand Up @@ -103,7 +103,8 @@ public string IcoPath
public IconDelegate Icon { get; set; }

/// <summary>
/// Gets or sets return true to hide wox after select result
/// Gets or sets the result action.
/// Return <c>true</c> to hide PowerToys Run after the result has been selected.
/// </summary>
[JsonIgnore]
public Func<ActionContext, bool> Action { get; set; }
Expand Down

0 comments on commit aa6910a

Please sign in to comment.