PowerShellEditorServices
PowerShellEditorServices copied to clipboard
VSC doesn't handle code completion for files and filepaths correctly
The wordDefinition property in VSC includes the "." and "" characters as word separators. This makes the completion suggestions complete incorrectly.
For example, since any suggestion with "" or "." is not a word the following problems will happen: Type 'notepa' and choose 'notepad.exe' and it will complete as 'notepad.exe'. However if you type 'notepad.e' and choose 'notepad.exe' and it will complete as 'notepad.notepad.exe'.
Or
Type 'C:' and there will be a list of paths to choose from, but if you keep typing '_C:_' the examples go away. If you still continue to type a real path like 'C:\Use' the suggestion 'C:\Users' will come up but if you choose it will complete as C:\C:\Users.
This is not immediately solvable by just removing '.' and '' from the list of separators as it causes different problems.
Removing '.' makes it so it's not longer a trigger character, so suggestion support doesn't work on anything needing '.'.
Removing '' doesn't reliably fix the completions problem because the auto completions only happen once you do the following: Type 'C:', then press the spacebar, then press backspace.
This works a lot better now after migrating to the vscode-powershell package. There are still some cases that need to be addressed correctly, though. For example, start with the following line:
& 'C:\Program Files (x86)'
After the final single-quote, type '' to trigger path IntelliSense and then select one of the recommendations. In my case, the result looks like this:
& 'C:\Program Files (x86)''C:\Program Files (x86)\Git'
...when it should look like this:
& 'C:\Program Files (x86)\Git'
This still needs to be improved to reach ISE-level compatibility. One thing the ISE does that PSES doesn't is continue giving completions if you use a forward slash after the string:
& 'C:\Program Files (x86)'
Typing a forward slash \ after the closing single-quote continues the path IntelliSense in the ISE but does nothing in VS Code. We should smooth out that experience so that we have great path IntelliSense.