Skip to content

References CodeLens provider does not show indicators in Untitled files #507

Closed

Description

@dfinke

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

Activity

  1. daviwil commented on Jun 10, 2017

    @daviwil
    Contributor

    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.

  2. changed the title [-]Pester CodeLens does not show indicators for and Untitled file[/-] [+]References CodeLens provider does not show indicators in Untitled files[/+] on Jun 10, 2017
  3. dfinke commented on Jun 10, 2017

    @dfinke
    ContributorAuthor

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

  4. modified the milestones: June 2017, on Oct 27, 2017
  5. TylerLeonhardt commented on Jan 10, 2018

    @TylerLeonhardt
    Member

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

  6. SeeminglyScience commented on Jan 11, 2018

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

  7. added a commit that references this issue on Feb 26, 2019
    0590230
  8. removed this from the milestone on Aug 17, 2021
  9. fflaten commented on Feb 7, 2023

    @fflaten
    Contributor

    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
  10. andyleejordan commented on Jun 15, 2026

    @andyleejordan
    Member

    Resolved by #1839 (v3.4.4) — CodeLens now works in untitled files. Closing as completed.


    Drafted by GitHub Copilot (Claude Opus 4.8) at Andy Jordan (@andyleejordan)'s request.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions