PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.71k stars 488 forks source link

Infinite formatting for entire document #1601

Closed PrzemyslawKlys closed 5 years ago

PrzemyslawKlys commented 5 years ago

System Details

System Details Output

### VSCode version: 1.28.2 7f3ce96ff4729c91352ae6def877e59c561f4850 x64

### VSCode extensions:
aaron-bond.better-comments@2.0.3
abusaidm.html-snippets@0.2.1
AlanWalk.markdown-toc@1.5.6
alefragnani.Bookmarks@9.1.0
azemoh.one-monokai@0.3.7
ban.spellright@3.0.6
batisteo.vscode-django@0.17.0
bierner.markdown-preview-github-styles@0.1.4
DavidAnson.vscode-markdownlint@0.21.0
DavidWang.ini-for-vscode@0.0.4
donjayamanne.githistory@0.4.3
donjayamanne.jupyter@1.1.4
donjayamanne.python-extension-pack@1.4.0
DotJoshJohnson.xml@2.3.2
eamodio.gitlens@8.5.6
emilast.LogFileHighlighter@2.4.2
emmanuelbeziat.vscode-great-icons@2.1.44
Equinusocio.vsc-material-theme@2.5.1
felixfbecker.php-debug@1.12.6
formulahendry.code-runner@0.9.5
gerane.Theme-dimmed-monokai@0.0.2
gharveymn.nightswitch@1.1.0
GitHub.vscode-pull-request-github@0.2.3
GlenBuktenica.unicode-substitutions@2.0.0
GrapeCity.gc-excelviewer@2.1.26
hdg.live-html-previewer@0.3.0
hnw.vscode-auto-open-markdown-preview@0.0.4
HookyQR.beautify@1.4.7
IBM.output-colorizer@0.1.2
ikappas.phpcs@1.0.5
ionutvmi.reg@0.0.2
JerryHong.autofilename@0.1.3
joaompinto.asciidoctor-vscode@0.15.1
johnpapa.winteriscoming@0.8.0
Kelvin.vscode-sshfs@1.11.1
kisstkondoros.vscode-codemetrics@1.17.3
KnisterPeter.vscode-github@0.30.0
magicstack.MagicPython@1.1.0
mariorodeghiero.vue-theme@1.1.1
mechatroner.rainbow-csv@0.7.1
mkloubert.vs-deploy@14.0.0
mkloubert.vscode-remote-workspace@0.37.0
ms-mssql.mssql@1.4.0
ms-python.python@2018.9.2
ms-vscode.csharp@1.17.0
ms-vscode.PowerShell@1.9.0
ms-vsliveshare.vsliveshare@0.3.897
ms-vsts.team@1.144.1
pnp.polacode@0.2.2
quicktype.quicktype@12.0.46
redhat.java@0.33.0
robertohuertasm.vscode-icons@7.28.0
Shan.code-settings-sync@3.2.0
stkb.rewrap@1.9.1
streetsidesoftware.code-spell-checker@1.6.10
streetsidesoftware.code-spell-checker-polish@1.0.0
swyphcosmo.spellchecker@1.2.13
TomasHubelbauer.zip-file-system@1.0.0
vangware.dark-plus-material@1.4.3
VisualStudioExptTeam.vscodeintellicode@1.0.5
vscjava.vscode-java-debug@0.15.0
vscjava.vscode-java-pack@0.4.0
vscjava.vscode-java-test@0.10.0
vscjava.vscode-maven@0.11.1
WakaTime.vscode-wakatime@1.2.3
wayou.vscode-todo-highlight@1.0.4
whizkydee.material-palenight-theme@1.9.4
wholroyd.jinja@0.0.8
xaver.clang-format@1.6.2
zhuangtongfa.Material-theme@2.17.7
Zignd.html-css-class-completion@1.11.0

### PSES version: 1.9.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      5.1.17763.1
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.1
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

First of all, I wanted to apologize. I know I am reporting a lot of issues and it may be just me, or the way I do modules or the way I set up folders, symlinks, Onedrives, so feel free to tell me to stop and I'll go and sob in the corner with no hard feelings.

I am experiencing a problem with... infinite formatting of the entire document. Whatever I do on this project of mine it seems to take ages to format document if it ever does.

This is this module: https://github.com/EvotecIT/PSSharedGoods

Feel free to copy it and play with it for longer while if needed. Basically, it's my "put all module" where I create a new file, function and just put it there for use. It seems like when formatting happens it's like scanning all the data in that module (at least I've noticed formating takes less time on smaller modules and quite a lot of time on larger ones).

What more is that it ignores any timeouts for formatting.

I've made movie for you. Whether I run (it will format on F5), whether I press CTRL+S to save or whether I choose an option to format document it bahaves the same way. formatonsave

11/6/2018 9:45:10 PM [NORMAL] - Language server starting --
11/6/2018 9:45:10 PM [NORMAL] -     exe: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
11/6/2018 9:45:10 PM [NORMAL] -     args: C:\Users\pklys\.vscode\extensions\ms-vscode.powershell-1.9.0\modules\PowerShellEditorServices\Start-EditorServices.ps1 -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '1.9.0'-AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'C:\Users\pklys\.vscode\extensions\ms-vscode.powershell-1.9.0\modules'-EnableConsoleRepl -LogLevel 'Diagnostic' -LogPath 'C:\Users\pklys\.vscode\extensions\ms-vscode.powershell-1.9.0\logs\1541537110-ac4928e4-2369-454e-b50b-6c4546c25f521541496923691\EditorServices.log' -SessionDetailsPath 'C:\Users\pklys\.vscode\extensions\ms-vscode.powershell-1.9.0\sessions\PSES-VSCode-8584-936334' -FeatureFlags @()
11/6/2018 9:45:11 PM [NORMAL] - powershell.exe started, pid: 20328
11/6/2018 9:45:12 PM [NORMAL] - Language server started.
11/6/2018 9:45:12 PM [NORMAL] - {"status":"started","debugServiceTransport":"NamedPipe","languageServiceTransport":"NamedPipe","debugServicePipeName":"\\\\.\\pipe\\PSES_c7c23d4f-d753-4a6d-8100-699d850fcfc8","languageServicePipeName":"\\\\.\\pipe\\PSES_954ea1c5-97ec-448a-b486-2134dedc50d2"}
11/6/2018 9:45:12 PM [NORMAL] - Language service connected.
11/6/2018 9:45:12 PM [NORMAL] - Connecting to language service on pipe \\.\pipe\PSES_954ea1c5-97ec-448a-b486-2134dedc50d2...
11/6/2018 9:45:18 PM [VERBOSE] - Formatting entire document - file:///c%3A/Users/pklys/OneDrive%20-%20Evotec/Support/GitHub/PSSharedGoods/Public/Connectivity/Connect-WinService.ps1...
11/6/2018 9:47:25 PM [VERBOSE] - Document formatting finished in 126.293s

Expected Behaviour

1-2 seconds max.

Actual Behaviour

126 seconds, and not formatted document

Attached Logs

Follow the instructions in the troubleshooting docs about capturing and sending logs.

1541537110-ac4928e4-2369-454e-b50b-6c4546c25f521541496923691.zip

rkeithhill commented 5 years ago

First of all, I wanted to apologize. I know I am reporting a lot of issues and it may be just me, or the way I do modules or the way I set up folders, symlinks, Onedrives, so feel free to tell me to stop and I'll go and sob in the corner with no hard feelings.

No problem. Keep the issue reports coming. Hopefully you don't get too discouraged with the slow progress getting your issues sorted out. The first step is getting repro's on our end. Fortunately I was able to repro the Problems window issue on my machine. I'll be looking into that one shortly.

PrzemyslawKlys commented 5 years ago

I know things take time, and repro is a must. Considering each dev has different needs, and does stuff differently. I don't expect anything instantly. I have my share of issues with my projects so I know how hard it can be to help a user.

rjmholt commented 5 years ago

@PrzemyslawKlys We really want to fix your issues, especially since they are likely to be a fairly common scenario (and are a good litmus test of our setup).

We just need to get around to it.

TylerLeonhardt commented 5 years ago

@PrzemyslawKlys I'm also going to dupe this to #1232. Formatting as a whole needs some perf work. We will work as hard as possible to get to this.

potatoqualitee commented 5 years ago

Hello, Working on dbatools in VS Code gives a similar problem of infinite formatting. It'd say solid formatting works about 25% of the time.

In our module, in order to speed up importing, we compile all commands into allcommands.ps1, and it's constantly in this file finding issues and potentially formatting.

If specific larger files are causing problems is there a way to ignore the larger files until the performance gets fixed?

Thanks much

rkeithhill commented 5 years ago

Can you update to PSScriptAnalyzer 1.18 and see if this issue still persists? PSSA provides the script formatting features for the extension. 1.18 was released a few days ago and significantly improves perf. You can install it like so Install-Module PSScriptAnalyzer -Scope CurrentUser -Force. If formatting issues persist, please file an issue in the PSSA repo - https://github.com/powershell/scriptanalyzer/issues

PrzemyslawKlys commented 5 years ago

I did update that but it brings some formatting problems - https://github.com/PowerShell/PSScriptAnalyzer/issues/1187

I had to uninstall to not break my current formatting. Hopefully, with new VSCode, this will be addressed.

rkeithhill commented 5 years ago

Thanks for submitting that issue to the PSSA repo! I'm going to leave this issue closed because, as I mentioned, PSSA provides all the formatting features for this extension.