Vscode-powershell: References are counted multiple times for similar named functions

Created on 16 Jul 2020  路  10Comments  路  Source: PowerShell/vscode-powershell

Issue Description

I am experiencing a problem with...references being counted multiple times. It seems like "like" is used for comparison and it doesn't look for exact match but with a wildcard.

function Invoke-GPOTest {

}

function Invoke-GPOTestOld {

}

Invoke-GPOTestOld

image

Find References

image

Find References for Invoke-GPOTranslation

image

Attached Logs

Follow the instructions in the README about
capturing and sending logs.

Environment Information

Visual Studio Code

| Name | Version |
| --- | --- |
| Operating System | Windows_NT x64 10.0.19041 |
| VSCode | 1.47.1|
| PowerShell Extension Version | 2020.6.1 |

PowerShell Information

|Name|Value|
|---|---|
|PSVersion|5.1.19041.1|
|PSEdition|Desktop|
|PSCompatibleVersions|1.0 2.0 3.0 4.0 5.0 5.1.19041.1|
|BuildVersion|10.0.19041.1|
|CLRVersion|4.0.30319.42000|
|WSManStackVersion|3.0|
|PSRemotingProtocolVersion|2.3|
|SerializationVersion|1.1.0.1|

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)

|Extension|Author|Version|
|---|---|---|
|bracket-pair-colorizer-2|CoenraadS|0.2.0|
|code-settings-sync|Shan|3.4.3|
|github-linker|gimenete|0.2.3|
|gitlens|eamodio|10.2.2|
|markdown-all-in-one|yzhang|3.1.0|
|material-icon-theme|PKief|4.2.0|
|powershell-preview|ms-vscode|2020.6.1|
|project-manager|alefragnani|11.1.0|
|run-in-powershell|tobysmith568|1.0.1|
|vscode-markdownlint|DavidAnson|0.36.1|
|vscode-pull-request-github|GitHub|0.18.0|
|vscode-toggle-quotes|BriteSnow|0.3.3|
|vscode-wakatime|WakaTime|4.0.0|
|vscode-yaml|redhat|0.9.1|
|xml|DotJoshJohnson|2.5.0|

Area-Symbols & References Issue-Bug Needs-Repro-Info

Most helpful comment

I've got a fix out for this.

All 10 comments

Thanks @PrzemyslawKlys it seems like some/all results are being being counted twice, and unfortunately we cant repro this--it would be really helpful if you could also attach the logs--instructions for how to do that are here

I'm curious also if you click on one of these:
image
where they take you?

1594906372-ed180bde-03b7-4479-8c96-8966ac6a7eed1594906371018.zip

I can reproduce it even in newly open code, in different folders.

When i click on those, it doesn't move me. It's showing exactly same place, just doubled.

Thanks @PrzemyslawKlys we took a good look at your logs, and unfortunately could not find the resulting bug in the logs...if you have time to provide more logs that would be great...the other possibility is that this is a bug in the VSCode client

I can probably provide more logs, it looks really weird.

image

Above shows a very weird thing:

  • There is a function defined
  • This function is used somewhere
  • It shows 1 reference (correctly)
  • Then I add in the same file as a function another reference
  • And now it shows 3, even tho when I click it shows just 2

@TylerLeonhardt could you look at this issue, and add it some priority. I know you guys work on other features but this has been bugging me for a while now providing wrong number of references misinforming me about them most of the time.


function Test-Function {
    param(
        $Something
    )
    Write-Output 'Green'
}
function Test-Function1 {
    param(
        $Something
    )
    Write-Output "Here's something I execute 1"
    Write-Output ([PSCUstomObject] @{ Test = 'News'; 'Test2' = 'test1' })
}
function Test-Function2 {
    param(
        $Something
    )
    Write-Output "Here's something I execute 2"
    [PSCUstomObject] @{ Test = 'News'; 'Test2' = 'test1' }
}
Test-Function
Test-Function1
Test-Function2

image

image

I can always reproduce it, on multiple computers.

I'm getting a similar issue to this, here's my payload log:
PayloadLogfile.zip

I found that this was only happening when my file was in a subfolder, and when I moved my file out of the subfolder, references were counted properly. But when I moved it back, the reference counts doubled again. I don't know if that's significant or not, but I thought I'd at least mention it.

Messing around further, it seems like the function declaration and the double-counted functions calls must be in the same file. Function references from a different file are counted normally.

Powershell-ext-two-files-compare

  • The left file holds the function declarations, while the right just has some function calls.
  • DetectAndRemoveNewLines is really used 3 times: 2x in the left file, 1x in the right file. Results in 5 references.
  • InitialCommentsHighlight is really used 4 times: 3x in the left file, 1x in the right file. Results in 7 references.
  • AnotherTestFile is really used 1 time: 1x in the right file. Results in 1 reference.
  • InSameFile is really used 1 time: 1x in the left file. Results in 2 references.

Here's my files from the image above if anyone else wants to have a look: SeeingDouble.zip

Looks like this is only happening on Windows.... investigating.

I've got a fix out for this.

Was this page helpful?
0 / 5 - 0 ratings