Skip to content

Commit 69f48e9

Browse files
author
Kapil Borle
committed
Add test to find variable defn with special chars in name
1 parent f367650 commit 69f48e9

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,36 @@ await this.SendRequest(
485485
Assert.Equal(20, locations[0].Range.End.Character);
486486
}
487487

488+
[Fact]
489+
public async Task FindDefinitionOfVariableWithSpecialChars()
490+
{
491+
await this.SendOpenFileEvent("TestFiles\\FindReferences.ps1");
492+
493+
Location[] locations =
494+
await this.SendRequest(
495+
DefinitionRequest.Type,
496+
new TextDocumentPositionParams
497+
{
498+
TextDocument = new TextDocumentIdentifier
499+
{
500+
Uri = "TestFiles\\FindReferences.ps1"
501+
},
502+
Position = new Position
503+
{
504+
Line = 18,
505+
Character = 24,
506+
}
507+
});
508+
509+
Assert.NotNull(locations);
510+
Assert.Equal(1, locations.Length);
511+
Assert.EndsWith("FindReferences.ps1", locations[0].Uri);
512+
Assert.Equal(17, locations[0].Range.Start.Line);
513+
Assert.Equal(0, locations[0].Range.Start.Character);
514+
Assert.Equal(17, locations[0].Range.End.Line);
515+
Assert.Equal(27, locations[0].Range.End.Character);
516+
}
517+
488518
[Fact]
489519
public async Task FindsOccurencesOnFunctionDefinition()
490520
{

test/PowerShellEditorServices.Test.Host/TestFiles/FindReferences.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ Write-Output ""
1414

1515
. .\VariableDefinition.ps1
1616
Write-Output $variableInOtherFile
17+
18+
${variable-with-weird-name} = "this variable has special characters"
19+
Write-Output ${variable-with-weird-name}

0 commit comments

Comments
 (0)