vscode-powershell: Error/warning detection is randomly broken

Repro:

  1. open VS Code
  2. ctrl+n, ctrl+s, save as foobar.ps1
  3. paste: $test = @{ "item1" = @("foo"); "item1" = @("bar") } then ctrl+s
  4. unused warning for $test, and duplicate keys error for second item1 won’t appear
  5. open a new line, type write-host "hello" and save, then the warning and error should appear.
  6. empty whole first line, ctrl+s, red error underline remains on empty char 1
  7. paste $test = @{ "item1" = @("foo"); "item2" = @("bar") }, now error is displayed after the closing brace
  8. you can keep randomly bugging it out, sometimes it will display a duplicate error for unique keys, sometimes it won’t show an error for duplicate keys. Sometimes opening a new line will fix it, sometimes it won’t. Sometimes adding a new statement on a new line, then saving fixes it, sometimes it won’t. It gets worse the more statements and braces you have. Sometimes if you delete a block (if, while, switch, etc.), the error jumps to the next closing brace, or the previous opening brace, and so on and so forth. And of course it’s not just duplicate keys or unused variables, any kind of syntax problem will occur and stick around even if you fixed it long ago.

Happens to me all the time on at least 3 different computers (2 desktops, 1 laptop; 1 in domain, 2 in workgroup).

Windows 10 1709 16299.309 VS Code 1.21.1 PowerShell 6.0.2 PowerShell Extension 1.6.0

Basically any version that’s been released since January, it happens on all of them, constantly.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

Thanks a lot, really appreciate it!

I’m going to clone RudeHash and try to repro this on a couple OS’s.

I can repro on PS Core 6.0.2 but not with Windows PS 5.1.

@tylerl0706 and I talked, this might have something to do with the size of the flat .ps1 you’re working with on you project. But it’s certainly not the biggest .ps1 I’ve ever seen (here’s what PowerShellGet looked like before a recent refactor), so it’s reasonable that we should work better with larger files like that.