Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

References are counted multiple times for similar named functions #2810

Closed
PrzemyslawKlys opened this issue Jul 16, 2020 · 10 comments · Fixed by PowerShell/PowerShellEditorServices#1348

Comments

@PrzemyslawKlys
Copy link
Contributor

PrzemyslawKlys commented Jul 16, 2020

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
@ghost ghost added the Needs: Triage Maintainer attention needed! label Jul 16, 2020
@SydneyhSmith
Copy link
Collaborator

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

@SydneyhSmith
Copy link
Collaborator

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

@SydneyhSmith SydneyhSmith added Needs-Repro-Info and removed Needs: Triage Maintainer attention needed! labels Jul 16, 2020
@PrzemyslawKlys
Copy link
Contributor Author

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.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jul 16, 2020
@SydneyhSmith
Copy link
Collaborator

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

@SydneyhSmith SydneyhSmith added Issue-Bug A bug to squash. Area-Symbols & References and removed Needs: Maintainer Attention Maintainer attention needed! labels Jul 21, 2020
@PrzemyslawKlys
Copy link
Contributor Author

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

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jul 21, 2020
@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Jul 28, 2020
@PrzemyslawKlys
Copy link
Contributor Author

@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.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Aug 2, 2020
@Kmek
Copy link

Kmek commented Aug 7, 2020

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.

@Kmek
Copy link

Kmek commented Aug 7, 2020

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

@TylerLeonhardt
Copy link
Member

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

@TylerLeonhardt
Copy link
Member

I've got a fix out for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants