Skip to content

VSCode PowerShell syntax highlighting 'messed up' by changing file under VSCode #3247

Open
@charliearcuri

Description

@charliearcuri

20210315 1615856510-81b75b36-ddce-47dd-b292-72c53676f7601615855631823.zip
20210315 VSCode PowerShell syntax highlighting 'messed up' by changing file under VSCode

Issue Description

I am experiencing a problem with syntax highlighting when a .ps1 changes underneath VSCode.
Similarly, some changes cause PSScriptAnalyzer issues (e.g. "missing }" warnings that I could not make sense of)

Repro Steps

  1. open VSCode - open output folder of my VS2019 project
  2. open SDF-UefiFlash.ps1 using VSCode's Explorer
  3. observe syntax highlighting (it is correct at this point)
  4. close SDF-UefiFlash.ps1 in VSCode but keep the folder open
  5. while keeping VSCode open, open VS2019 and open the solution that contains SDF-UefiFlash.ps1 in addition to a .NET class library used by the .ps1 script
  6. In VS2019, make a change to SDF-UefiFlash.ps1 - this file being modified here is checked into git. The change I made was to add a .PARAMETER definition to the synopsis at the top of the file.
  7. rebuild all in VS2019 - this copies the newly changed version of SDF-UefiFlash.ps1 to the output folder that VSCode has open
  8. re-open SDF-UefiFlash.ps1 in VSCode

Expected Behaviour

The syntax highlighting works when I open a .ps1 in VSCode even if I have used VS2019 to update the file and published it to the folder VSCode has opened by 'rebuilding all' in VS2019.

Actual Behaviour

If I "rebuild all" in VS2019 while VSCode has the output folder open, when I open the .ps1 (which is copied to the output folder by the VS2019 rebuild all), the syntax highlighting is "messed up" - presumably because VSCode has some information about the syntax highlighting cached.

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.19042
VSCode 1.54.3
PowerShell Extension Version 2021.2.2

PowerShell Information

Name Value
PSVersion 7.1.3
PSEdition Core
GitCommitId 7.1.3
OS Microsoft Windows 10.0.19042
Platform Win32NT
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.10032.0 6.0.0 6.1.0 6.2.0 7.0.0 7.1.3
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)
Extension Author Version
cpptools ms-vscode 1.2.2
jupyter ms-toolsai 2021.3.619093157
powershell ms-vscode 2021.2.2
python ms-python 2021.2.636928669

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