Check that the plugin that returned the result actually put in a selection action in there

This commit is contained in:
Betsegaw Tadele 2020-05-03 15:52:00 -07:00
parent 8d9dd378e7
commit e679751ea6

View File

@ -6,7 +6,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Input;
using Wox.Infrastructure.UserSettings;
using Wox.Plugin;
@ -18,8 +18,8 @@ namespace Wox.ViewModel
public ResultCollection Results { get; }
private ResultViewModel _selectedItem;
private ResultViewModel _selectedItem;
private int _selectedIndex;
private readonly object _addResultsLock = new object();
@ -50,44 +50,47 @@ namespace Wox.ViewModel
public int MaxHeight => MaxResults * 50;
public int SelectedIndex
{
get
{
return _selectedIndex;
}
set
{
if (value != _selectedIndex)
{
_selectedIndex = value;
SelectedItem = Results[_selectedIndex];
}
}
public int SelectedIndex
{
get
{
return _selectedIndex;
}
set
{
if (value != _selectedIndex)
{
_selectedIndex = value;
SelectedItem = Results[_selectedIndex];
}
}
}
public ResultViewModel SelectedItem
public ResultViewModel SelectedItem
{
get { return _selectedItem; }
set
{
//value can be null when selecting an item in a virtualized list
if (value != null)
{
if (_selectedItem != null)
{
_selectedItem.DeactivateContextButtons(ResultViewModel.ActivationType.Selection);
}
_selectedItem = value;
_selectedItem.ActivateContextButtons(ResultViewModel.ActivationType.Selection);
_selectedItem.Result.SelectionAction(new ActionContext());
}
else
{
_selectedItem = value;
}
set
{
//value can be null when selecting an item in a virtualized list
if (value != null)
{
if (_selectedItem != null)
{
_selectedItem.DeactivateContextButtons(ResultViewModel.ActivationType.Selection);
}
_selectedItem = value;
_selectedItem.ActivateContextButtons(ResultViewModel.ActivationType.Selection);
if (_selectedItem.Result.SelectionAction != null)
{
_selectedItem.Result.SelectionAction(new ActionContext());
}
}
else
{
_selectedItem = value;
}
}
}
@ -170,26 +173,26 @@ namespace Wox.ViewModel
public void RemoveResultsFor(PluginMetadata metadata)
{
Results.RemoveAll(r => r.Result.PluginID == metadata.ID);
}
public void SelectNextTabItem()
{
if(!SelectedItem.SelectNextContextButton())
{
SelectNextResult();
}
}
public void SelectPrevTabItem()
{
if (!SelectedItem.SelectPrevContextButton())
{
//Tabbing backwards should highlight the last item of the previous row
SelectPrevResult();
SelectedItem.SelectLastContextButton();
}
}
}
public void SelectNextTabItem()
{
if(!SelectedItem.SelectNextContextButton())
{
SelectNextResult();
}
}
public void SelectPrevTabItem()
{
if (!SelectedItem.SelectPrevContextButton())
{
//Tabbing backwards should highlight the last item of the previous row
SelectPrevResult();
SelectedItem.SelectLastContextButton();
}
}
/// <summary>
/// To avoid deadlock, this method should not called from main thread
/// </summary>