Skip to content

Commit e83249e

Browse files
committed
Other PR feedback
1 parent b0fa794 commit e83249e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Diff for: src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Diagnostics/TaskListDiagnosticProvider.cs

+14-4
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ public static ImmutableArray<LspDiagnostic> GetTaskListDiagnostics(RazorCodeDocu
3636

3737
foreach (var token in taskListDescriptors)
3838
{
39-
if (i + token.Length + 2 > comment.EndCommentStar.SpanStart || // Enough room in the comment for the token and some content?
40-
!Matches(source, i, token) || // Does the prefix match?
41-
char.IsLetter(source[i + token.Length + 1])) // Is there something after the prefix, so we don't match "TODOLOL"
39+
if (!CommentMatchesToken(source, comment, i, token))
4240
{
4341
continue;
4442
}
@@ -61,8 +59,14 @@ public static ImmutableArray<LspDiagnostic> GetTaskListDiagnostics(RazorCodeDocu
6159
return diagnostics.ToImmutable();
6260
}
6361

64-
private static bool Matches(SourceText source, int i, string token)
62+
private static bool CommentMatchesToken(SourceText source, RazorCommentBlockSyntax comment, int i, string token)
6563
{
64+
if (i + token.Length + 2 > comment.EndCommentStar.SpanStart)
65+
{
66+
// Not enough room in the comment for the token and some content
67+
return false;
68+
}
69+
6670
for (var j = 0; j < token.Length; j++)
6771
{
6872
if (source.Length < i + j)
@@ -76,6 +80,12 @@ private static bool Matches(SourceText source, int i, string token)
7680
}
7781
}
7882

83+
if (char.IsLetter(source[i + token.Length + 1]))
84+
{
85+
// The comment starts with the token, but the next character is a letter, which means it is something like "TODONT"
86+
return false;
87+
}
88+
7989
return true;
8090
}
8191
}

0 commit comments

Comments
 (0)