PowerShellEditorServices icon indicating copy to clipboard operation
PowerShellEditorServices copied to clipboard

References CodeLens provider does not show indicators in Untitled files

Open dfinke opened this issue 8 years ago • 5 comments

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

dfinke avatar Jun 10 '17 18:06 dfinke

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 avatar Jun 10 '17 18:06 daviwil

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

dfinke avatar Jun 10 '17 18:06 dfinke

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

TylerLeonhardt avatar Jan 10 '18 21:01 TylerLeonhardt

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

SeeminglyScience avatar Jan 11 '18 13:01 SeeminglyScience

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

fflaten avatar Feb 07 '23 19:02 fflaten