Skip to content

Commit 3ca1d5a

Browse files
committed
Handle inconsistent results from Find All references gracefullt
The results of Find All References take the input code from the reference's line in the VBE and the highlight selection based on the reference selection. If this happens in a dirty state, the highlight can be outside the input code on the line that is now on the line the reference was on before. Previously, this caused an ArgumentOutOfBoundExcetion in the UI code when applying the highlight, which brought down the host. Now, we check whether the highlight is within the input code and only apply it if this check passes. The navigation properly navigates to the last known selection of the reference.
1 parent 12f50e5 commit 3ca1d5a

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)