Skip to content

Commit ec8cf7b

Browse files
committed
Short-circuit find-definition when given definition
1 parent 494b0d9 commit ec8cf7b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/PowerShellEditorServices/Services/TextDocument/Handlers/DefinitionHandler.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ public override async Task<LocationOrLocationLinks> Handle(DefinitionParams requ
4343
request.Position.Line + 1,
4444
request.Position.Character + 1);
4545

46+
// Short-circuit if we're already on the definition.
47+
if (foundSymbol.IsDeclaration)
48+
{
49+
return new LocationOrLocationLinks(
50+
new LocationOrLocationLink[] {
51+
new LocationOrLocationLink(
52+
new Location
53+
{
54+
Uri = DocumentUri.From(foundSymbol.FilePath),
55+
Range = foundSymbol.NameRegion.ToRange()
56+
})});
57+
}
58+
4659
List<LocationOrLocationLink> definitionLocations = new();
4760
if (foundSymbol is not null)
4861
{

0 commit comments

Comments
 (0)