diff --git a/extensions/json-language-features/client/src/jsonClient.ts b/extensions/json-language-features/client/src/jsonClient.ts index 18aec8ef32b..0741cb8743b 100644 --- a/extensions/json-language-features/client/src/jsonClient.ts +++ b/extensions/json-language-features/client/src/jsonClient.ts @@ -71,6 +71,7 @@ namespace SettingIds { export const enableFormatter = 'json.format.enable'; export const enableSchemaDownload = 'json.schemaDownload.enable'; export const maxItemsComputed = 'json.maxItemsComputed'; + export const maxItemsExceededInformation = 'json.maxItemsExceededInformation'; } export interface TelemetryReporter { @@ -298,8 +299,19 @@ export function startClient(context: ExtensionContext, newLanguageClient: Langua } })); - client.onNotification(ResultLimitReachedNotification.type, message => { - window.showInformationMessage(`${message}\n${localize('configureLimit', 'Use setting \'{0}\' to configure the limit.', SettingIds.maxItemsComputed)}`); + client.onNotification(ResultLimitReachedNotification.type, async message => { + const shouldPrompt = workspace.getConfiguration().get(SettingIds.maxItemsExceededInformation) !== false; + if (shouldPrompt) { + const ok = localize('ok', "Ok"); + const openSettings = localize('goToSetting', 'Open Settings'); + const neverAgain = localize('yes never again', "Don't Show Again"); + const pick = await window.showInformationMessage(`${message}\n${localize('configureLimit', 'Use setting \'{0}\' to configure the limit.', SettingIds.maxItemsComputed)}`, ok, openSettings, neverAgain); + if (pick === neverAgain) { + await workspace.getConfiguration().update(SettingIds.maxItemsExceededInformation, false, true); + } else if (pick === openSettings) { + await commands.executeCommand('workbench.action.openSettings', SettingIds.maxItemsComputed); + } + } }); function updateFormatterRegistration() { diff --git a/extensions/json-language-features/package.json b/extensions/json-language-features/package.json index db003f05121..5899ebc9fdf 100644 --- a/extensions/json-language-features/package.json +++ b/extensions/json-language-features/package.json @@ -97,6 +97,11 @@ "default": 5000, "description": "%json.maxItemsComputed.desc%" }, + "json.maxItemsExceededInformation": { + "type": "boolean", + "default": true, + "description": "%json.maxItemsExceededInformation.desc%" + }, "json.schemaDownload.enable": { "type": "boolean", "default": true, diff --git a/extensions/json-language-features/package.nls.json b/extensions/json-language-features/package.nls.json index 59729a0ee99..9315f7f2fed 100644 --- a/extensions/json-language-features/package.nls.json +++ b/extensions/json-language-features/package.nls.json @@ -13,5 +13,6 @@ "json.schemaResolutionErrorMessage": "Unable to resolve schema.", "json.clickToRetry": "Click to retry.", "json.maxItemsComputed.desc": "The maximum number of outline symbols and folding regions computed (limited for performance reasons).", + "json.maxItemsExceededInformation.desc": "Show notification when exceeding the maximum number of outline symbols and folding regions.", "json.enableSchemaDownload.desc": "When enabled, JSON schemas can be fetched from http and https locations." }