Skip to content

Commit ef5d4e1

Browse files
committed
Add back loop breaker
1 parent 9761b13 commit ef5d4e1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/CompletionListCache.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Licensed under the MIT license. See License.txt in the project root for license information.
33

44
using System.Diagnostics.CodeAnalysis;
5+
using Microsoft.AspNetCore.Razor;
6+
using Microsoft.AspNetCore.Razor.Language.Components;
57
using Microsoft.VisualStudio.LanguageServer.Protocol;
68

79
namespace Microsoft.CodeAnalysis.Razor.Completion;
@@ -65,6 +67,14 @@ public bool TryGet(int id, [NotNullWhen(true)] out VSInternalCompletionList? com
6567

6668
var slot = _items[index];
6769

70+
// CompletionList is annotated as non-nullable, but we are allocating an array of 10 items for our cache, so initially
71+
// those array entries will be default. By checking for null here, we detect if we're hitting an unused part of the array
72+
// so stop looping.
73+
if (slot.CompletionList is null)
74+
{
75+
break;
76+
}
77+
6878
if (slot.Id == id)
6979
{
7080
completionList = slot.CompletionList;

0 commit comments

Comments
 (0)