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 CodeLens provider does not show indicators in Untitled files #507

Open
dfinke opened this issue Jun 10, 2017 · 5 comments
Open
Labels

Comments

@dfinke
Copy link
Contributor

dfinke commented Jun 10, 2017

You need to save the file and then the indicators appear above the Describe statement.

@daviwil
Copy link
Contributor

daviwil commented Jun 10, 2017

Thanks man! This is because we're checking the file extension to see if it ends with .tests.ps1 before returning symbols, but maybe we should support authoring in untitled files too.

However, now that I think about it, you can't run a Pester test without it being saved to a file... This does actually affect the References CodeLens provider though, so I'll make a fix for that.

@daviwil daviwil changed the title Pester CodeLens does not show indicators for and Untitled file References CodeLens provider does not show indicators in Untitled files Jun 10, 2017
@daviwil daviwil added the Issue-Bug A bug to squash. label Jun 10, 2017
@daviwil daviwil added this to the June 2017 milestone Jun 10, 2017
@dfinke
Copy link
Contributor Author

dfinke commented Jun 10, 2017

You can F5 the file before saving and it runs the tests.

@daviwil daviwil modified the milestones: June 2017, Backlog Oct 27, 2017
@TylerLeonhardt
Copy link
Member

@daviwil do you think you could elaborate on how it affects the References CodeLens provider?

@SeeminglyScience
Copy link
Collaborator

@tylerl0706 This if statement needs to support untitled tabs that contain PowerShell. The main difficulty would be determining that it's definitely PowerShell. Trying to run that on untitled tabs with different languages could cause some nasty unexpected issues.

TylerLeonhardt pushed a commit to TylerLeonhardt/PowerShellEditorServices that referenced this issue Feb 26, 2019
This change adds support for CodeLenses that display the number of
references of a given function or cmdlet defined in a script file.  The
actual implementation of this behavior is on the server side but we had
to write a LanguageClient middleware to translate the arguments of the
references command when it was sent from the server.

Resolves PowerShell#507
Resolves PowerShell#827 (unrelated to CodeLenses but related to LanguageClient
output)
@andyleejordan andyleejordan removed this from the Backlog milestone Aug 17, 2021
@fflaten
Copy link
Contributor

fflaten commented Feb 7, 2023

Status: Ready to close?

Code lens appears after #1098. Command references in untitled documents (with PowerShell language set) are counted since #1917 (included in vscode-powershell v2022.9.0)

Pester code lens (Run/Debug Tests) still require *.tests.ps1 saved files and that should continue imo. to avoid accidently passing this ps1-file to Invoke-Pester just because it mentions Describe/Context/It in a internal scriptblock:

$c = New-PesterConfiguration
$containers = (New-PesterContainer -Data @{ abc = 'def' } -ScriptBlock {
    Describe 'd1' {
        Context '123' {
            It 'a' -Tag 'a.d' { 1 | should -be 1 }
            It 'b' -Tag 'a.d' { 1 | should -be 1 } -Skip
        }
    }
})

$c.Run.Container = $containers
$r = Invoke-Pester -Configuration $c

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

No branches or pull requests

6 participants