From 871c112422652d7f9c93ca7c12b43d5b585530bd Mon Sep 17 00:00:00 2001 From: Jamie Cansdale Date: Tue, 25 Sep 2018 10:44:05 +0100 Subject: [PATCH] Fix for crash when search includes white-space SearchAsync will crash the process if we send it a duplicate string. There is a SearchTrimsWhitespace setting that makes searched with leading or trailing white-space appear as duplicates. We compare the query with trimmed white-space to avoid this. --- src/GitHub.VisualStudio/UI/GitHubPane.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/GitHub.VisualStudio/UI/GitHubPane.cs b/src/GitHub.VisualStudio/UI/GitHubPane.cs index 498d5cf4ca..a62a6f7723 100644 --- a/src/GitHub.VisualStudio/UI/GitHubPane.cs +++ b/src/GitHub.VisualStudio/UI/GitHubPane.cs @@ -169,8 +169,13 @@ void UpdateSearchHost(bool enabled, string query) { SearchHost.IsEnabled = enabled; - if (SearchHost.SearchQuery?.SearchString != query) + var searchString = SearchHost.SearchQuery?.SearchString; + if (searchString?.Trim() != query?.Trim()) { + // SearchAsync will crash the process if we send it a duplicate string. + // There is a SearchTrimsWhitespace setting that makes searched with leading or trailing + // white-space appear as duplicates. We compare the query with trimmed white-space to avoid this. + // https://github.com/github/VisualStudio/issues/1948 SearchHost.SearchAsync(query != null ? new SearchQuery(query) : null); } }