Skip to content

Commit 4e63fa5

Browse files
committed
Revert document mapping service changes
1 parent b751e89 commit 4e63fa5

File tree

3 files changed

+4
-21
lines changed

3 files changed

+4
-21
lines changed

src/Razor/src/Microsoft.AspNetCore.Razor.LanguageServer/RazorDocumentMappingService.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -332,19 +332,6 @@ public bool TryMapToHostDocumentPosition(IRazorGeneratedDocument generatedDocume
332332
return true;
333333
}
334334

335-
foreach (var mapping in generatedDocument.GeneratedOnlyMappings)
336-
{
337-
var generatedAbsoluteIndex = mapping.AbsoluteIndex;
338-
var distanceIntoGeneratedSpan = generatedDocumentIndex - generatedAbsoluteIndex;
339-
if (generatedAbsoluteIndex <= generatedDocumentIndex &&
340-
distanceIntoGeneratedSpan <= mapping.Length)
341-
{
342-
hostDocumentIndex = 0;
343-
hostDocumentPosition = new LinePosition(0, 0);
344-
return true;
345-
}
346-
}
347-
348335
hostDocumentPosition = default;
349336
hostDocumentIndex = default;
350337
return false;

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,10 @@ 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 hostDocumentStartIndex) &&
163-
_documentMappingService.TryMapToHostDocumentPosition(csharpDocument, absoluteCSharpStartIndex + length, out var _2, out var hostDocumentEndIndex))
162+
if (_documentMappingService.TryMapToHostDocumentPosition(csharpDocument, absoluteCSharpStartIndex, out var _1, out var hostDocumentIndex) &&
163+
_documentMappingService.TryMapToHostDocumentPosition(csharpDocument, absoluteCSharpStartIndex + length, out var _2, out var _3))
164164
{
165-
var mappedLength = hostDocumentEndIndex - hostDocumentStartIndex;
166-
if (mappedLength > 0)
167-
{
168-
ranges.Add(new(kind, hostDocumentStartIndex, mappedLength));
169-
}
165+
ranges.Add(new(kind, hostDocumentIndex, length));
170166
}
171167

172168
absoluteCSharpStartIndex += length;

src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/DocumentSymbols/DocumentSymbolEndpointTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class DocumentSymbolEndpointTest(ITestOutputHelper testOutput) : SingleSe
2222
public Task DocumentSymbols_CSharpMethods()
2323
=> VerifyDocumentSymbolsAsync(
2424
"""
25-
{|AspNetCore.test:|}@functions {
25+
@functions {
2626
private void {|HandleString(string s):HandleString|}(string s)
2727
{
2828
s += "Hello";

0 commit comments

Comments
 (0)