Remove too many folding regions notification (#163854)

* Remove too many folding regions notification

* remove duplicate folding limit item for JSON/JSONC

* polish

* fix test
This commit is contained in:
Martin Aeschlimann
2022-10-17 23:42:02 +02:00
committed by GitHub
parent fb5b553316
commit c83eff40dd
14 changed files with 239 additions and 85 deletions

View File

@@ -68,8 +68,9 @@ The server supports the following settings:
- `fileMatch`: an array of file names or paths (separated by `/`). `*` can be used as a wildcard. Exclusion patterns can also be defined and start with '!'. A file matches when there is at least one matching pattern and the last matching pattern is not an exclusion pattern.
- `url`: The URL of the schema, optional when also a schema is provided.
- `schema`: The schema content.
- `resultLimit`: The max number folding ranges and outline symbols to be computed (for performance reasons)
- `resultLimit`: The max number of color decorators and outline symbols to be computed (for performance reasons)
- `jsonFoldingLimit`: The max number of folding ranges to be computed for json documents (for performance reasons)
- `jsoncFoldingLimit`: The max number of folding ranges to be computed for jsonc documents (for performance reasons)
```json
{
"http": {
@@ -187,7 +188,8 @@ Notification:
### Item Limit
If the setting `resultLimit` is set, the JSON language server will limit the number of folding ranges and document symbols computed.
If the setting `resultLimit` is set, the JSON language server will limit the number of color symbols and document symbols computed.
If the setting `jsonFoldingLimit` or `jsoncFoldingLimit` is set, the JSON language server will limit the number of folding ranges computed.
## Try

View File

@@ -106,8 +106,9 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
let hierarchicalDocumentSymbolSupport = false;
let foldingRangeLimitDefault = Number.MAX_VALUE;
let foldingRangeLimit = Number.MAX_VALUE;
let resultLimit = Number.MAX_VALUE;
let jsonFoldingRangeLimit = Number.MAX_VALUE;
let jsoncFoldingRangeLimit = Number.MAX_VALUE;
let formatterMaxNumberOfEdits = Number.MAX_VALUE;
let diagnosticsSupport: DiagnosticsSupport | undefined;
@@ -187,6 +188,8 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
keepLines?: { enable?: boolean };
validate?: { enable?: boolean };
resultLimit?: number;
jsonFoldingLimit?: number;
jsoncFoldingLimit?: number;
};
http?: {
proxy?: string;
@@ -217,8 +220,10 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
keepLinesEnabled = settings.json?.keepLines?.enable || false;
updateConfiguration();
foldingRangeLimit = Math.trunc(Math.max(settings.json?.resultLimit || foldingRangeLimitDefault, 0));
resultLimit = Math.trunc(Math.max(settings.json?.resultLimit || Number.MAX_VALUE, 0));
const sanitizeLimitSetting = (settingValue: any) => Math.trunc(Math.max(settingValue, 0));
resultLimit = sanitizeLimitSetting(settings.json?.resultLimit || Number.MAX_VALUE);
jsonFoldingRangeLimit = sanitizeLimitSetting(settings.json?.jsonFoldingLimit || foldingRangeLimitDefault);
jsoncFoldingRangeLimit = sanitizeLimitSetting(settings.json?.jsoncFoldingLimit || foldingRangeLimitDefault);
// dynamically enable & disable the formatter
if (dynamicFormatterRegistration) {
@@ -437,7 +442,8 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
return runSafe(runtime, () => {
const document = documents.get(params.textDocument.uri);
if (document) {
return languageService.getFoldingRanges(document, { rangeLimit: foldingRangeLimit });
const rangeLimit = document.languageId === 'jsonc' ? jsoncFoldingRangeLimit : jsonFoldingRangeLimit;
return languageService.getFoldingRanges(document, { rangeLimit });
}
return null;
}, null, `Error while computing folding ranges for ${params.textDocument.uri}`, token);