In history window support searching tags

This commit is contained in:
Jaex 2021-05-26 01:53:34 +03:00
parent 5500e4d553
commit e1ee32f7cd

View file

@ -39,6 +39,7 @@ public partial class HistoryForm : Form
{
public string HistoryPath { get; private set; }
public HistorySettings Settings { get; private set; }
public bool SearchInTags { get; set; } = true;
private HistoryManager history;
private HistoryItemManager him;
@ -213,8 +214,9 @@ private HistoryItem[] ApplyFilters(HistoryItem[] historyItems)
if (!string.IsNullOrEmpty(filenameFilter))
{
string pattern = Regex.Escape(filenameFilter).Replace("\\?", ".").Replace("\\*", ".*");
Regex regex = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
result = result.Where(x => x.FileName != null && regex.IsMatch(x.FileName));
Regex regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
result = result.Where(x => (x.FileName != null && regex.IsMatch(x.FileName)) ||
(SearchInTags && x.Tags != null && x.Tags.Any(tag => regex.IsMatch(tag.Value))));
}
string urlFilter = txtURLFilter.Text;