Fixed process executing on clicking enter if no text in search box

This commit is contained in:
Divyansh Srivastava 2020-04-23 13:57:26 -07:00
parent 65cda38cc8
commit d0822ab1fe
2 changed files with 37 additions and 29 deletions

View File

@ -152,32 +152,35 @@ namespace Wox.ViewModel
results.SelectedIndex = int.Parse(index.ToString());
}
//If there is a context button selected fire the action for that button before the main command.
bool didExecuteContextButton = results.SelectedItem?.ExecuteSelectedContextButton() ?? false;
if (!didExecuteContextButton)
if(results.SelectedItem != null)
{
var result = results.SelectedItem?.Result;
if (result != null) // SelectedItem returns null if selection is empty.
//If there is a context button selected fire the action for that button before the main command.
bool didExecuteContextButton = results.SelectedItem?.ExecuteSelectedContextButton() ?? false;
if (!didExecuteContextButton)
{
bool hideWindow = result.Action != null && result.Action(new ActionContext
var result = results.SelectedItem?.Result;
if (result != null) // SelectedItem returns null if selection is empty.
{
SpecialKeyState = GlobalHotkey.Instance.CheckModifiers()
});
bool hideWindow = result.Action != null && result.Action(new ActionContext
{
SpecialKeyState = GlobalHotkey.Instance.CheckModifiers()
});
if (hideWindow)
{
MainWindowVisibility = Visibility.Collapsed;
}
if (hideWindow)
{
MainWindowVisibility = Visibility.Collapsed;
}
if (SelectedIsFromQueryResults())
{
_userSelectedRecord.Add(result);
_history.Add(result.OriginQuery.RawQuery);
}
else
{
SelectedResults = Results;
if (SelectedIsFromQueryResults())
{
_userSelectedRecord.Add(result);
_history.Add(result.OriginQuery.RawQuery);
}
else
{
SelectedResults = Results;
}
}
}
}
@ -419,6 +422,7 @@ namespace Wox.ViewModel
}
else
{
Results.SelectedItem = null;
Results.Clear();
Results.Visbility = Visibility.Collapsed;
}

View File

@ -65,6 +65,10 @@ namespace Wox.ViewModel
_selectedItem = value;
_selectedItem.ActivateContextButtons(ResultViewModel.ActivationType.Selection);
}
else
{
_selectedItem = value;
}
}
}