diff --git a/ShareX.HistoryLib/Forms/ImageHistoryForm.cs b/ShareX.HistoryLib/Forms/ImageHistoryForm.cs index 7a73be586..72144bb83 100644 --- a/ShareX.HistoryLib/Forms/ImageHistoryForm.cs +++ b/ShareX.HistoryLib/Forms/ImageHistoryForm.cs @@ -40,6 +40,7 @@ public partial class ImageHistoryForm : Form public string HistoryPath { get; private set; } public ImageHistorySettings Settings { get; private set; } public string SearchText { get; set; } + public bool SearchInTags { get; set; } = true; private HistoryManager history; private HistoryItemManager him; @@ -124,7 +125,7 @@ private IEnumerable GetHistoryItems() if (!string.IsNullOrEmpty(SearchText)) { string pattern = Regex.Escape(SearchText).Replace("\\?", ".").Replace("\\*", ".*"); - regex = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); + regex = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); } for (int i = historyItems.Count - 1; i >= 0; i--) @@ -132,7 +133,7 @@ private IEnumerable GetHistoryItems() HistoryItem hi = historyItems[i]; if (!string.IsNullOrEmpty(hi.FilePath) && Helpers.IsImageFile(hi.FilePath) && - (regex == null || regex.IsMatch(hi.FileName)) && + (regex == null || regex.IsMatch(hi.FileName) || (SearchInTags && hi.Tags != null && hi.Tags.Any(tag => regex.IsMatch(tag.Value)))) && (!Settings.FilterMissingFiles || File.Exists(hi.FilePath))) { filteredHistoryItems.Add(hi);