diff --git a/extensions/json/client/src/jsonMain.ts b/extensions/json/client/src/jsonMain.ts index 60733f1dc25..c6b51503df9 100644 --- a/extensions/json/client/src/jsonMain.ts +++ b/extensions/json/client/src/jsonMain.ts @@ -70,7 +70,7 @@ export function activate(context: ExtensionContext) { // The server is implemented in node let serverModule = context.asAbsolutePath(path.join('server', 'out', 'jsonServerMain.js')); // The debug options for the server - let debugOptions = { execArgv: ['--nolazy', '--inspect=6046'] }; + let debugOptions = { execArgv: ['--nolazy', '--inspect=' + (9000 + Math.round(Math.random() * 10000))] }; // If the extension is launch in debug mode the debug server options are use // Otherwise the run options are used diff --git a/extensions/json/language-configuration.json b/extensions/json/language-configuration.json index 53ccbd23546..9a73ac64aae 100644 --- a/extensions/json/language-configuration.json +++ b/extensions/json/language-configuration.json @@ -12,6 +12,7 @@ { "open": "[", "close": "]", "notIn": ["string"] }, { "open": "(", "close": ")", "notIn": ["string"] }, { "open": "'", "close": "'", "notIn": ["string"] }, + { "open": "/*", "close": "*/", "notIn": ["string"] }, { "open": "\"", "close": "\"", "notIn": ["string", "comment"] }, { "open": "`", "close": "`", "notIn": ["string", "comment"] } ] diff --git a/extensions/json/server/src/jsonServerMain.ts b/extensions/json/server/src/jsonServerMain.ts index 943201db631..fa77f9a039e 100644 --- a/extensions/json/server/src/jsonServerMain.ts +++ b/extensions/json/server/src/jsonServerMain.ts @@ -7,7 +7,7 @@ import { createConnection, IConnection, TextDocuments, TextDocument, InitializeParams, InitializeResult, NotificationType, RequestType, - DocumentRangeFormattingRequest, Disposable, ServerCapabilities, DocumentColorRequest, ColorPresentationRequest, + DocumentRangeFormattingRequest, Disposable, ServerCapabilities, DocumentColorRequest, ColorPresentationRequest, Position, } from 'vscode-languageserver'; import { xhr, XHRResponse, configure as configureHttpRequests, getErrorStatusDescription } from 'request-light'; @@ -18,7 +18,7 @@ import Strings = require('./utils/strings'); import { formatError, runSafe, runSafeAsync } from './utils/errors'; import { JSONDocument, JSONSchema, getLanguageService, DocumentLanguageSettings, SchemaConfiguration } from 'vscode-json-languageservice'; import { getLanguageModelCache } from './languageModelCache'; -import { createScanner, SyntaxKind } from 'jsonc-parser'; +import { createScanner, SyntaxKind, ScanError } from 'jsonc-parser'; import { FoldingRangeType, FoldingRangesRequest, FoldingRange, FoldingRangeList, FoldingProviderServerCapabilities } from './protocol/foldingProvider.proposed'; @@ -393,9 +393,13 @@ connection.onRequest(FoldingRangesRequest.type, params => { case SyntaxKind.BlockCommentTrivia: { let startLine = document.positionAt(scanner.getTokenOffset()).line; let endLine = document.positionAt(scanner.getTokenOffset() + scanner.getTokenLength()).line; - if (startLine < endLine) { - ranges.push({ startLine, endLine, type: FoldingRangeType.Comment }); - prevStart = startLine; + if (scanner.getTokenError() === ScanError.UnexpectedEndOfComment && startLine + 1 < document.lineCount) { + scanner.setPosition(document.offsetAt(Position.create(startLine + 1, 0))); + } else { + if (startLine < endLine) { + ranges.push({ startLine, endLine, type: FoldingRangeType.Comment }); + prevStart = startLine; + } } break; }