mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
Prevent from accessing last results if query has changed
This commit is contained in:
@@ -46,6 +46,7 @@ namespace Wox
|
|||||||
private bool WinRStroked;
|
private bool WinRStroked;
|
||||||
private NotifyIcon notifyIcon;
|
private NotifyIcon notifyIcon;
|
||||||
private bool queryHasReturn;
|
private bool queryHasReturn;
|
||||||
|
private string lastQuery;
|
||||||
private ToolTip toolTip = new ToolTip();
|
private ToolTip toolTip = new ToolTip();
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
@@ -182,6 +183,7 @@ namespace Wox
|
|||||||
{
|
{
|
||||||
if (ignoreTextChange) { ignoreTextChange = false; return; }
|
if (ignoreTextChange) { ignoreTextChange = false; return; }
|
||||||
|
|
||||||
|
lastQuery = tbQuery.Text;
|
||||||
toolTip.IsOpen = false;
|
toolTip.IsOpen = false;
|
||||||
resultCtrl.Dirty = true;
|
resultCtrl.Dirty = true;
|
||||||
Dispatcher.DelayInvoke("UpdateSearch",
|
Dispatcher.DelayInvoke("UpdateSearch",
|
||||||
@@ -195,18 +197,18 @@ namespace Wox
|
|||||||
// didn't.
|
// didn't.
|
||||||
if (resultCtrl.Dirty) resultCtrl.Clear();
|
if (resultCtrl.Dirty) resultCtrl.Clear();
|
||||||
}, TimeSpan.FromMilliseconds(100), null);
|
}, TimeSpan.FromMilliseconds(100), null);
|
||||||
var q = new Query(tbQuery.Text);
|
var q = new Query(lastQuery);
|
||||||
CommandFactory.DispatchCommand(q);
|
CommandFactory.DispatchCommand(q);
|
||||||
queryHasReturn = false;
|
queryHasReturn = false;
|
||||||
if (Plugins.HitThirdpartyKeyword(q))
|
if (Plugins.HitThirdpartyKeyword(q))
|
||||||
{
|
{
|
||||||
Dispatcher.DelayInvoke("ShowProgressbar", originQuery =>
|
Dispatcher.DelayInvoke("ShowProgressbar", originQuery =>
|
||||||
{
|
{
|
||||||
if (!queryHasReturn && originQuery == tbQuery.Text)
|
if (!queryHasReturn && originQuery == lastQuery)
|
||||||
{
|
{
|
||||||
StartProgress();
|
StartProgress();
|
||||||
}
|
}
|
||||||
}, TimeSpan.FromSeconds(0), tbQuery.Text);
|
}, TimeSpan.FromSeconds(0), lastQuery);
|
||||||
}
|
}
|
||||||
}, TimeSpan.FromMilliseconds((isCMDMode = tbQuery.Text.StartsWith(">")) ? 0 : 150));
|
}, TimeSpan.FromMilliseconds((isCMDMode = tbQuery.Text.StartsWith(">")) ? 0 : 150));
|
||||||
}
|
}
|
||||||
@@ -371,7 +373,7 @@ namespace Wox
|
|||||||
|
|
||||||
private void AcceptSelect(Result result)
|
private void AcceptSelect(Result result)
|
||||||
{
|
{
|
||||||
if (result != null)
|
if (!resultCtrl.Dirty && result != null)
|
||||||
{
|
{
|
||||||
if (result.Action != null)
|
if (result.Action != null)
|
||||||
{
|
{
|
||||||
@@ -409,7 +411,7 @@ namespace Wox
|
|||||||
}
|
}
|
||||||
Dispatcher.DelayInvoke("ShowResult", k => resultCtrl.Dispatcher.Invoke(new Action(() =>
|
Dispatcher.DelayInvoke("ShowResult", k => resultCtrl.Dispatcher.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
List<Result> l = waitShowResultList.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == tbQuery.Text).ToList();
|
List<Result> l = waitShowResultList.Where(o => o.OriginQuery != null && o.OriginQuery.RawQuery == lastQuery).ToList();
|
||||||
waitShowResultList.Clear();
|
waitShowResultList.Clear();
|
||||||
resultCtrl.AddResults(l);
|
resultCtrl.AddResults(l);
|
||||||
})), TimeSpan.FromMilliseconds(isCMDMode ? 0 : 50));
|
})), TimeSpan.FromMilliseconds(isCMDMode ? 0 : 50));
|
||||||
|
|||||||
Reference in New Issue
Block a user