Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[json] Reduce "The number of foldable regions is limited to a maximum of 5000" pop up #142496

Closed
jasonwilliams opened this issue Feb 8, 2022 · 17 comments · Fixed by #153104
Closed
Assignees
Labels
editor-folding Editor code folding issues feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan plan-item VS Code - planned item for upcoming
Milestone

Comments

@jasonwilliams
Copy link
Contributor

jasonwilliams commented Feb 8, 2022

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.64
  • OS Version: MacOS

https://code.visualstudio.com/updates/v1_64#_editor-folding-limit

Since updating to version 1.64 I'm getting notifications constantly about folded regions. The files I have open are not that big so I don't know why this is coming up or what it wants me to do. 5000 is already a lot so I don't need to increase it.

VSCode has enough pop-ups as it is and this is just adding to the noise. What is the call-to-action here? I find it confusing and I'm not sure why its asking me to increase the foldable regions.

image

@aeschli
Copy link
Contributor

aeschli commented Feb 8, 2022

We had issues from users that found that folding ranges were missing and understand why.

But yes, I'm also not a fan of notifications with information that is not relevant to me.

@jrieken What would you say, is the language indicator a better place for this?

@jrieken
Copy link
Member

jrieken commented Feb 8, 2022

@jrieken What would you say, is the language indicator a better place for this?

Yeah, that might be fair use of it. Either a message specific about folding or a more generic large file info (in case this also affect after features)

@PieterBranderhorst
Copy link
Contributor

@jasonwilliams Am I right to assume that the file you're opening when you get this message is well over 10,000 lines long? If not it shouldn't be possible to have that many foldable regions.

It should be ok to increase the limit, after clicking on 'Folding Maximum Regions', to 20,000 or more. The 5,000 limit is fairly conservative.

@rebeccapeltz
Copy link

I started getting a Debug Terminal open when I opened the terminal. Now I'm getting this message. Are these related?

@PieterBranderhorst
Copy link
Contributor

@rebeccapeltz I can't think of a way these two things could be related. One way to find out would be to click on 'Folding Maximum Regions' in this message when it comes up, increase the limit enough that it stops coming up (try say 20,000) and see if the Debug Terminal continues to open even when this message is no longer coming up.

@keaedwar
Copy link

I get this popup if I open a package-lock.json file, which the current one I'm looking at is 42,415 lines. I'm not going to edit it, but I was in vscode and just wanted to see the top few lines that have the file version.

@aeschli aeschli added editor-folding Editor code folding issues feature-request Request for new features or functionality labels Mar 1, 2022
@aeschli aeschli added this to the Backlog milestone Mar 1, 2022
@mstange
Copy link

mstange commented Mar 12, 2022

In the meantime, can this warning be removed again? It pops up very frequently. It might save some time for users who were confused by the missing folding ranges, but it wastes a lot of time for users who don't care about folding.

@PieterBranderhorst
Copy link
Contributor

@mstange Have you tried bumping that limit to 20,000? Or if you never care about folding at all then you could turn it off by opening settings ( Ctrl+, ), type "folding", and uncheck the top option there.

@aeschli Also, how about bumping that default to 10,000? Or, if you don't mind reviewing some code rework to make that area faster, bump the default to 20,000 or more?

@mstange
Copy link

mstange commented Apr 5, 2022

@mstange Have you tried bumping that limit to 20,000?

It helps for my 60000 line plain text file, thanks. It probably won't help for the other cases where I encountered it: When I pipe long command line output into code -. I think that case would be improved by not attempting code folding on editors that haven't been saved as files (and where the "language" has been inferred from the contents rather than from the file extension).

Or if you never care about folding at all then you could turn it off

I care about code folding in code. But I also use VS Code on files that are not code: Plain text files and logs. Especially logs are the ones that are likely to be very big. I don't need code folding in those files.

@MattGrdinic
Copy link

Agree with others in needing a better justification for constantly notifying me of this condition.

To that end would be nice to understand why and where this is happening. Within an admittedly large project I don't recall more than a handful of folds I've created, though I do have a few external components so knowing where would be really helpful.

@PieterBranderhorst
Copy link
Contributor

@MattGrdinic This is happening because a "folding range provider" is returning a large number of foldable regions. Those are marked with the downward chevron (like a wide "v") in the margin just left of the text when you hover the cursor there.

If you have one or more extensions which provide folding ranges for a particular language then that's where they are coming from. Some of those are built-in, e.g. for Typescript. If there's no extension present which provides folding ranges for a language then they're coming from the default indent-based provider. That provider creates a foldable range at every line in the source where the next line has a larger indent.

You can disable folding range provider(s) for a particular language or all languages via "editor folding" in vscode settings.

@aeschli Do you think this issue could be resolved by changing that message, about too many folding regions, to be an information level message in the problems panel? I've looked around for how to use that panel in vscode and haven't figured it out yet. If you'd like it moved there a pointer on how to do it would help.

@aeschli
Copy link
Contributor

aeschli commented May 17, 2022

@PieterBranderhorst Agree that the notification is too prominent. The idea is to use the language indicator instead:
E.g. JSON already uses the language indicator API:
image

@PieterBranderhorst
Copy link
Contributor

@aeschli I was thinking more of adding a message in the problems panel:

problems

@aeschli
Copy link
Contributor

aeschli commented May 18, 2022

@PieterBranderhorst We currently use the problems view only for resource based diagnostics, so I don't think we should put it there.

@TonyGravagno
Copy link

PMJI with a solution - I found this thread specifically with a search for this new issue...

Exactly as noted by @mstange - I'm getting this in a project where I'm looking at huge .log files.

I see editor.foldingMaximumRegions was added a few months ago. There's actually a little oversight/bug in this implementation that's key to this issue. This feature was implemented to be language-specific. Example:

"[log]": {
   "editor.foldingMaximumRegions": 11,
   "something.else": value
},
"[php]": {
   "editor.foldingMaximumRegions": 22,
   "unrelated.setting": value
}

If you set two languages like that you'll see the warnings change with the correct maximum. However, click on the warning where it offers to change the config, and the setting gets saved outside of the scope of the language. So you don't get the above, you get something like this:

// attempt to evade the nag
"editor.foldingMaximumRegions": 40000,
"[log]": {
   "something.else": value
},
"[php]": {
   "unrelated.setting": value
}

That's a new issue for a different ticket. What's relevant here is that there is another setting editor.folding, and that's also language-specific. So to disable folding for .log files, while preserving folding for .php files with a reasonable warning value, this is the settings.json detail:

"[log]": {
   // no need to set max regions
   "editor.folding": false,
},
"[php]": {
   // be sure folding is active for this language
   "editor.folding": true,
   // reasonable warning trigger
   "editor.foldingMaximumRegions": 10000,
},
// increase warning default above 5000 for all languages except as specified
"editor.foldingMaximumRegions": 30000,

With this, the warning serves the intended purpose, and doesn't get triggered outside of that scope.

HTH

@aeschli aeschli modified the milestones: Backlog, June 2022 Jun 24, 2022
@aeschli aeschli changed the title Reduce "The number of foldable regions is limited to a maximum of 5000" pop up [json] Reduce "The number of foldable regions is limited to a maximum of 5000" pop up Jun 24, 2022
aeschli added a commit that referenced this issue Jun 24, 2022
* reduce number of json notifications

* use language indicator for folding limit warnings. For #142496

* add comment for resultLimit + 1
@VSCodeTriageBot VSCodeTriageBot added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jun 24, 2022
@aeschli
Copy link
Contributor

aeschli commented Jun 27, 2022

I pushed a change. We're now using the language indicator to inform about limited folding, outline and color symbols. No more notifications.

@mstange
Copy link

mstange commented Jun 27, 2022

Thank you!

@github-actions github-actions bot locked and limited conversation to collaborators Aug 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-folding Editor code folding issues feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan plan-item VS Code - planned item for upcoming
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants