ant-druha / intellij-powershell

Adds PowerShell language support to IntelliJ-based IDEs.
https://plugins.jetbrains.com/plugin/10249-powershell
Apache License 2.0
70 stars 19 forks source link

Extraneous parentheses cause errors to be reported on valid code #268

Open joshuaking-madtech opened 3 months ago

joshuaking-madtech commented 3 months ago

$rootString = if(($PSVersionTable).Platform -like "Unix"){"/"} else{"$env:SystemDrive*"} The parentheses around $PSVersionTable above are unnecessary but are valid; this should possibly make a style suggestion to remove them Working in PS 5.1 on Windows: image Ditto PS 7 on Linux: image

Plugin: image image

joshuaking-madtech commented 3 months ago

That's weird, it works fine after closing and re-opening Rider. I've had it a couple times now that it does something like this on obviously valid code after copy pasting code back and forth. I'll update if I manage to get a reliable reproduction.

ForNeVeR commented 3 months ago

I think it could happen in case the document model was suddenly desynchronized between the editor and the LSP server.

Could you please get the IDE logs, noting the exact time when something like this happens?

joshuaking-madtech commented 3 months ago

I think it could happen in case the document model was suddenly desynchronized between the editor and the LSP server.

Could you please get the IDE logs, noting the exact time when something like this happens?

Will do. It's been well behaved so far today but I'll keep an eye out.

Just to be a little more specific, when I was having problems yesterday I was copying most or all of the script I had started in ISE into Rider (and then promptly forgetting which one I'd made changes in last), and also pasting the script back and forth to a VM to test cross-platform. The clipboard sync to the VM (virt-viewer) sometimes takes a second to cough up the text after hitting paste.

ForNeVeR commented 3 months ago

Hopefully the clipboard sync shouldn't be an issue here: we do not query the clipboard anywhere in the plugin; we only look at the active document and sync it with the language server. I wonder if quick (or sudden) changes to it may cause some hiccups.

(And of course we want to fix these.)