Fix detection of nested symbols in Document Outline#68107
Fix detection of nested symbols in Document Outline#68107sharwell merged 1 commit intodotnet:mainfrom
Conversation
| { | ||
| var parentRange = ProtocolConversions.RangeToLinePositionSpan(parent.Range); | ||
| var childRange = ProtocolConversions.RangeToLinePositionSpan(child.Range); | ||
| return childRange.Start > parentRange.Start && childRange.End <= parentRange.End; |
There was a problem hiding this comment.
📝 This is a move from comparing line number to comparing position number. Since the LSP Position type didn't support the comparison, we convert to a Roslyn TextPosition which provides the > and <= operators.
| => new LinePosition(position.Line, position.Character); | ||
|
|
||
| public static LinePositionSpan RangeToLinePositionSpan(LSP.Range range) | ||
| => new(PositionToLinePosition(range.Start), PositionToLinePosition(range.End)); |
There was a problem hiding this comment.
📝 This is a restoration of a helper method that was recently removed in #68081 due to lack of use
| { | ||
| var request = parameterFactory(textBuffer.CurrentSnapshot).ToObject<RoslynDocumentSymbolParams>(); | ||
| var response = await testLspServer.ExecuteRequestAsync<RoslynDocumentSymbolParams, DocumentSymbol[]>(method, request!, cancellationToken); | ||
| var response = await testLspServer.ExecuteRequestAsync<RoslynDocumentSymbolParams, object[]>(method, request!, cancellationToken); |
There was a problem hiding this comment.
📝 The tests took longer than expected to write because this mock isn't the real call and didn't match the signature of the real call:
The use of DocumentSymbol[] was forcing it to serialize DocumentSymbol items, which is a base type of the actual RoslynDocumentSymbol items contained in this array, so all the items in the tests failed to have the Glyph property set.
Fixes #66012
Fixes #66473