Skip to content

Commit 1bb58c3

Browse files
authored
Merge pull request #6026 from MDoerner/StopCrashingOnFindReferencesInDirtyState
Handle inconsistent results from Find All references gracefully
2 parents 3dbdb29 + 3ca1d5a commit 1bb58c3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Rubberduck.Core/UI/Converters/SearchResultToXamlConverter.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
3333
textBlock.TextWrapping = TextWrapping.Wrap;
3434

3535
var input = item.ResultText.Replace(' ', nonBreakingSpace);
36-
if (item.HighlightIndex.HasValue)
36+
if (item.HighlightIndex.HasValue
37+
&& item.HighlightIndex.Value.EndColumn < input.Length // if we do not check this, any inconsistent input will crash the host.
38+
&& item.HighlightIndex.Value.StartColumn < input.Length)
3739
{
3840
var highlight = item.HighlightIndex.Value;
39-
if (highlight.StartColumn > 0)
41+
if (highlight.StartColumn > 0)
4042
{
4143
var preRun = new Run(input.Substring(0, highlight.StartColumn))
4244
{

0 commit comments

Comments
 (0)