Skip to content

Unfolding not always possible #2518

Closed
PowerShell/PowerShellEditorServices
#1238

Description

@DarkLite1

Issue Description

Since the last update of the PowerShell Preview extension there is an issue with unfolding certain code blocks. When refactoring some code you will see that pressing CTRL + 0 will collapse all regions but sometimes it's no longer possible to expand the regions by clicking on the arrow in front of the collapsed code. When doing this nothing is unfolding and after 10 to 15 seconds it does unfold sometimes, but not always.

It's pretty hard to replicate this as it happens randomly but quite often. Usually I run a Pester test script to test a script and then when I come back the folding becomes an issue.

System Details

VSCode version:

1.43.0-insider d1c48c103cabc6e729f59787c0b9c86fb3d39e73 x64

VSCode extensions:

[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

PSES version: 2.0.0.0

PowerShell version:

Name Value


PSVersion 5.1.14393.3471
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.3471
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Activity

  1. ghost added
    Needs: Triage
    on Mar 3, 2020
  2. rjmholt commented on Mar 3, 2020

    @rjmholt
    Contributor

    DarkLite1 (@DarkLite1) is there anything in the logs suggesting an error?

  3. TylerLeonhardt commented on Mar 3, 2020

    @TylerLeonhardt
    Member

    Also a sample script that you've seen this with would be very helpful.

  4. added and removed
    Needs: Triage
    on Mar 3, 2020
  5. DarkLite1 commented on Mar 4, 2020

    @DarkLite1
    Author

    I knew this question was coming ;) It's just very hard to consistently reproduce, but it happens quite often as in every 2 times after refactoring code.

    I've add some test code in attachment. When both files are open and you are in the file ``Set permissions.Tests.ps1and pressF5` to execute it, everything goes fine. Than you refactor something in the production file or the test file, press `CTRL + 0` or try to unfold a specific section and it will fail 1 out of 3 times. What's also not working is formatting code after refactoring, copy/pasting a pester `it` clause for example. When you do that and press `ALT + CTRL + F` nothing is happening for a while.

    I hope you guys (or girls) see something I can't see. Thanks anyhow for looking into this and sorry for not being able to be more precise.

    Test.zip

  6. ghost added
    Needs: Maintainer Attention
    on Mar 4, 2020
  7. DarkLite1 commented on Mar 5, 2020

    @DarkLite1
    Author

    Figured out how to reproduce this:

    1. Open the file Testie.ps1 in attachment
    2. Collapse all by using CTRL + K and CTRL + 0
    3. Open the top comment section of the file and add some random text in the comments or simply change the e-mail address in the last line AUTHOR [email protected]
    4. Try to click on the arrow before Process{ to unfold it
      Notice that unfolding that section is impossible

    image

    Testie.zip

  8. ili101 commented on Mar 5, 2020

    @ili101

    I can confirm this is something that started in the last release ([email protected]).
    But it's not an unfolding problem, it's everything the extension do hang for a long time.

    To reproduce do the steps DarkLite1 (@DarkLite1) provided in his last post.
    Add to step 4 more things like F8 on some line and hover over a variable to get the intelligence tooltip.
    The unfold will not work, the F8 will not execute and the tooltip will say "Loading..."
    Then wait for ~1 minute, it will suddenly unfold, Run the F8 and show the tooltip info.

    BTW is 2020.3.0 already on the way? Or can this be fix before that?

  9. rjmholt commented on Mar 5, 2020

    @rjmholt
    Contributor

    Does it work if you go into the console and press Ctrl+C?

  10. ili101 commented on Mar 5, 2020

    @ili101

    Does it work if you go into the console and press

    Ctrl+C doesn't seems to effect this.

  11. rjmholt commented on Mar 5, 2020

    @rjmholt
    Contributor

    DarkLite1 (@DarkLite1) could you post your example as text?

  12. rjmholt commented on Mar 5, 2020

    @rjmholt
    Contributor

    My observation is that extension spends a lot of time to analyze PS Script Analyzer along with my customized settings for it.

    Can you expand on this? How did you observe this? Does it seem to be interacting with folding?

  13. 33 remaining items

  14. ghost added
    Needs: Maintainer Attention
    on Apr 16, 2020
  15. SydneyhSmith commented on Apr 16, 2020

    @SydneyhSmith
    Collaborator

    ili101 thanks for your response could you please open a new issue with an ask for better performance for finding references of functions..thanks!

  16. DarkLite1 commented on Apr 17, 2020

    @DarkLite1
    Author

    Sydney Smith (@SydneyhSmith) why is a new ticket needed when the core problem is still there?

  17. ghost added
    Needs: Maintainer Attention
    on Apr 17, 2020
  18. TylerLeonhardt commented on Apr 17, 2020

    @TylerLeonhardt
    Member

    That's fair DarkLite1 (@DarkLite1).

    ili101 DarkLite1 (@DarkLite1) could you try disabling CodeLens to see if that helps at all:

    "editor.codeLens": true

  19. ili101 commented on Apr 18, 2020

    @ili101

    Hi TylerLeonhardt
    With "editor.codeLens": false there is no issue so it's something in there (At last I know I can tern it off when opening this big folder now)

    Edit: With the 10,000 folders it locks for a minute on every edit.
    I then change the test to create 10,000 ps1 files with "Test-TheBug" instead of the folders, with the files it locks for a minute once at load, detects all 10,000 references and then works without any problems.

    So with files it locks once to scans the references then manage to update the references on the fly without impacting performance, but with the folders it locks on every change continually

  20. TylerLeonhardt commented on Apr 18, 2020

    @TylerLeonhardt
    Member

    This is because CodeLens triggers on every edit - vscode controls this.
    And it recursively looking at the filesystem to generate references - we control this.

    Some concerns:

    • We don't know if something outside of VS Code put new files there that we haven't seen yet.
    • If you change something in your current file, that could potentially change the reference count and would need it to be re-computed.

    There's room for improvement here for sure. We could use a combination of file system watchers and caches to possibly increase perf here.

    I wonder if this is why TypeScript doesn't have CodeLens on by default 🤔too many node_modules folders... and a very computational operation...

  21. DarkLite1 commented on Apr 18, 2020

    @DarkLite1
    Author

    I encountered another issue that might be related to this. When I rename a folder in vs code and there are lots of node.js projects in those folders the renaming cannot happen. The system just keeps on waiting and errors out.

    Back to this topic, it might be related as I am using the PowerShell Preview extension. I think a file watcher would be a really great idea. It's then only fired when a single file is CRUD. That might fix the issue.

  22. TylerLeonhardt commented on Apr 18, 2020

    @TylerLeonhardt
    Member

    But keep in mind, that'll be tricky to implement because we can't keep too much in memory otherwise... #1613

  23. TylerLeonhardt commented on Apr 18, 2020

    @TylerLeonhardt
    Member

    so I don't think we're cancelling CodeLens requests at the moment (VS Code tells us to cancel them, but we need to implement what cancelling means)... Can you attach the logs here (and the payload logs!).

    I want to see how many times VS Code says to cancel CodeLens requests. If there are a lot, then we can implement cancelation (by doing something with the cancellation token here) that will help with performance.

  24. ghost closed this as completedon Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-FoldingIssue-Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions