diff --git a/Extension/src/LanguageServer/configurations.ts b/Extension/src/LanguageServer/configurations.ts index 28da4bec6f..066c4bc955 100644 --- a/Extension/src/LanguageServer/configurations.ts +++ b/Extension/src/LanguageServer/configurations.ts @@ -16,6 +16,7 @@ import { getCustomConfigProviders } from './customProviders'; import { SettingsPanel } from './settingsPanel'; import * as os from 'os'; import escapeStringRegExp = require('escape-string-regexp'); +import * as jsonc from 'jsonc-parser'; import * as nls from 'vscode-nls'; nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })(); @@ -959,7 +960,7 @@ export class CppProperties { } // Try to use the same configuration as before the change. - const newJson: ConfigurationJson = JSON.parse(readResults); + const newJson: ConfigurationJson = jsonc.parse(readResults); if (!newJson || !newJson.configurations || newJson.configurations.length === 0) { throw { message: localize("invalid.configuration.file", "Invalid configuration file. There must be at least one configuration present in the array.") }; } @@ -1276,7 +1277,7 @@ export class CppProperties { // Replace all \ with \\, except for \" // Otherwise, the JSON.parse result will have the \ missing. const configurationsText: string = util.escapeForSquiggles(curText); - const configurations: ConfigurationJson = JSON.parse(configurationsText); + const configurations: ConfigurationJson = jsonc.parse(configurationsText); const currentConfiguration: Configuration = configurations.configurations[this.CurrentConfigurationIndex]; let curTextStartOffset: number = 0;