Skip to content

Commit cd8cf20

Browse files
committed
Fix spell check endpoint
1 parent ae0914c commit cd8cf20

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/SpellCheck/DocumentSpellCheckEndpoint.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,14 @@ private async Task AddCSharpSpellCheckRangesAsync(List<SpellCheckRange> ranges,
159159

160160
// We need to map the start index to produce results, and we validate that we can map the end index so we don't have
161161
// squiggles that go from C# into Razor/Html.
162-
if (_documentMappingService.TryMapToHostDocumentPosition(csharpDocument, absoluteCSharpStartIndex, out var _1, out var hostDocumentIndex) &&
163-
_documentMappingService.TryMapToHostDocumentPosition(csharpDocument, absoluteCSharpStartIndex + length, out var _2, out var _3))
162+
if (_documentMappingService.TryMapToHostDocumentPosition(csharpDocument, absoluteCSharpStartIndex, out var _1, out var hostDocumentStartIndex) &&
163+
_documentMappingService.TryMapToHostDocumentPosition(csharpDocument, absoluteCSharpStartIndex + length, out var _2, out var hostDocumentEndIndex))
164164
{
165-
ranges.Add(new(kind, hostDocumentIndex, length));
165+
var mappedLength = hostDocumentEndIndex - hostDocumentStartIndex;
166+
if (mappedLength > 0)
167+
{
168+
ranges.Add(new(kind, hostDocumentStartIndex, mappedLength));
169+
}
166170
}
167171

168172
absoluteCSharpStartIndex += length;

0 commit comments

Comments
 (0)