Fixed Multi-filter issues (#77)

* 解决文件过滤和自带过滤不能同时使用的问题
* Removed redundant step in parsing filters from settings

---------

Co-authored-by: Lin Yu-Chieh (Victor) <victorlin@gapps.ntust.edu.tw>
This commit is contained in:
konglongbt 2024-01-13 11:24:37 +08:00 committed by Lin Yu-Chieh (Victor)
parent ef0a3e5a5e
commit 220c027f7d
2 changed files with 15 additions and 4 deletions

View File

@ -41,9 +41,20 @@ namespace Community.PowerToys.Run.Plugin.Everything
if (orgqry.Contains(':'))
{
string[] nqry = query.Split(':', 2);
if (setting.Filters.TryGetValue(nqry[0].ToLowerInvariant(), out string value))
query = nqry[1].Trim() + " ext:" + value;
fStringBuilder sb = new();
foreach (var kv in setting.Filters)
{
if (query.Contains(kv.Key, StringComparison.OrdinalIgnoreCase))
{
sb.Append(kv.Value + ';');
query = query.Replace(kv.Key, string.Empty);
}
}
if (sb.Length > 0)
{
query = query.Trim() + " ext:" + sb.ToString();
}
}
_ = Everything_SetSearchW(query);

View File

@ -35,7 +35,7 @@ namespace Community.PowerToys.Run.Plugin.Everything
if (kv.Length != 2) continue;
if (kv[0].Contains(':'))
Filters.TryAdd(kv[0].Split(':')[0].ToLowerInvariant(), kv[1]);
Filters.TryAdd(kv[0].ToLowerInvariant(), kv[1]);
}
}
}