From e1ee32f7cd553abc392a25d49a7e101075554b53 Mon Sep 17 00:00:00 2001 From: Jaex Date: Wed, 26 May 2021 01:53:34 +0300 Subject: [PATCH] In history window support searching tags --- ShareX.HistoryLib/Forms/HistoryForm.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ShareX.HistoryLib/Forms/HistoryForm.cs b/ShareX.HistoryLib/Forms/HistoryForm.cs index ec7d6e059..3971215fa 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.cs @@ -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;