Vscode-powershell: Error/warning detection is randomly broken

Created on 20 Mar 2018  路  16Comments  路  Source: PowerShell/vscode-powershell

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.

Area-IntelliSense Issue-Bug Issue-Performance

All 16 comments

It could be that I write code that's not too conventional and too prone to mess up IntelliSense, I really dunno. I'm a PowerShell noob, this is my first shot at it. Maybe just writing invalid code in rudehash.ps1, then fixing it will trigger this more easily. To me it happens every few minutes, which gets really irritating after a while.

Totally understandable and thank you so much for opening this! I couldn't repro what you are seeing on my mac but let me try a few other VMs and get back to you.

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

But it also happens with my 2 line example...

I've been speaking with @SeeminglyScience about this and he had some thoughts on why this was happening. Even for small files. It's entirely possible that the bigger the file, the more common this issue is which is why "large file" is quick to blame.

I'll continue investigating.

I C, that might very well be the case indeed. Thanks a lot for the quick responses, really appreciate it.

Definitely almost identical, tho I don't think closing and reopening the file ever solved this issue for me. Only a full Code restart.

This is one of my main focuses next week. I'll keep you updated.

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

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

Thanks a lot, really appreciate it!

Hey everyone, I'm having a super hard time repro'ing this. I won't stop trying, but if you DO run into this issue, please grab the logs and drop them here so I can take a look. It'll be really helpful. Thanks!

Exactly what kind of log?

We have some instructions here:
https://github.com/PowerShell/vscode-powershell/blob/master/README.md#2-capture-verbose-logs-and-send-them-to-us

It also includes turning on Verbose logs that is crucial. Diagnostic would be even better if it doesn't affect performance.

Closing this issue as inactive, will re-open if this is still an issue.

Was this page helpful?
0 / 5 - 0 ratings