Skip to content

Commit

Permalink
Revert document mapping service changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jjonescz committed Dec 13, 2023
1 parent b751e89 commit 4e63fa5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,19 +332,6 @@ public bool TryMapToHostDocumentPosition(IRazorGeneratedDocument generatedDocume
return true;
}

foreach (var mapping in generatedDocument.GeneratedOnlyMappings)
{
var generatedAbsoluteIndex = mapping.AbsoluteIndex;
var distanceIntoGeneratedSpan = generatedDocumentIndex - generatedAbsoluteIndex;
if (generatedAbsoluteIndex <= generatedDocumentIndex &&
distanceIntoGeneratedSpan <= mapping.Length)
{
hostDocumentIndex = 0;
hostDocumentPosition = new LinePosition(0, 0);
return true;
}
}

hostDocumentPosition = default;
hostDocumentIndex = default;
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,10 @@ private async Task AddCSharpSpellCheckRangesAsync(List<SpellCheckRange> ranges,

// 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
// squiggles that go from C# into Razor/Html.
if (_documentMappingService.TryMapToHostDocumentPosition(csharpDocument, absoluteCSharpStartIndex, out var _1, out var hostDocumentStartIndex) &&
_documentMappingService.TryMapToHostDocumentPosition(csharpDocument, absoluteCSharpStartIndex + length, out var _2, out var hostDocumentEndIndex))
if (_documentMappingService.TryMapToHostDocumentPosition(csharpDocument, absoluteCSharpStartIndex, out var _1, out var hostDocumentIndex) &&
_documentMappingService.TryMapToHostDocumentPosition(csharpDocument, absoluteCSharpStartIndex + length, out var _2, out var _3))
{
var mappedLength = hostDocumentEndIndex - hostDocumentStartIndex;
if (mappedLength > 0)
{
ranges.Add(new(kind, hostDocumentStartIndex, mappedLength));
}
ranges.Add(new(kind, hostDocumentIndex, length));
}

absoluteCSharpStartIndex += length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class DocumentSymbolEndpointTest(ITestOutputHelper testOutput) : SingleSe
public Task DocumentSymbols_CSharpMethods()
=> VerifyDocumentSymbolsAsync(
"""
{|AspNetCore.test:|}@functions {
@functions {
private void {|HandleString(string s):HandleString|}(string s)
{
s += "Hello";
Expand Down

0 comments on commit 4e63fa5

Please sign in to comment.