77import {
88 createConnection , IConnection ,
99 TextDocuments , TextDocument , InitializeParams , InitializeResult , NotificationType , RequestType ,
10- DocumentRangeFormattingRequest , Disposable , ServerCapabilities , DocumentColorRequest , ColorPresentationRequest ,
10+ DocumentRangeFormattingRequest , Disposable , ServerCapabilities , DocumentColorRequest , ColorPresentationRequest , Position ,
1111} from 'vscode-languageserver' ;
1212
1313import { xhr , XHRResponse , configure as configureHttpRequests , getErrorStatusDescription } from 'request-light' ;
@@ -18,7 +18,7 @@ import Strings = require('./utils/strings');
1818import { formatError , runSafe , runSafeAsync } from './utils/errors' ;
1919import { JSONDocument , JSONSchema , getLanguageService , DocumentLanguageSettings , SchemaConfiguration } from 'vscode-json-languageservice' ;
2020import { getLanguageModelCache } from './languageModelCache' ;
21- import { createScanner , SyntaxKind } from 'jsonc-parser' ;
21+ import { createScanner , SyntaxKind , ScanError } from 'jsonc-parser' ;
2222
2323import { FoldingRangeType , FoldingRangesRequest , FoldingRange , FoldingRangeList , FoldingProviderServerCapabilities } from './protocol/foldingProvider.proposed' ;
2424
@@ -393,9 +393,13 @@ connection.onRequest(FoldingRangesRequest.type, params => {
393393 case SyntaxKind . BlockCommentTrivia : {
394394 let startLine = document . positionAt ( scanner . getTokenOffset ( ) ) . line ;
395395 let endLine = document . positionAt ( scanner . getTokenOffset ( ) + scanner . getTokenLength ( ) ) . line ;
396- if ( startLine < endLine ) {
397- ranges . push ( { startLine, endLine, type : FoldingRangeType . Comment } ) ;
398- prevStart = startLine ;
396+ if ( scanner . getTokenError ( ) === ScanError . UnexpectedEndOfComment && startLine + 1 < document . lineCount ) {
397+ scanner . setPosition ( document . offsetAt ( Position . create ( startLine + 1 , 0 ) ) ) ;
398+ } else {
399+ if ( startLine < endLine ) {
400+ ranges . push ( { startLine, endLine, type : FoldingRangeType . Comment } ) ;
401+ prevStart = startLine ;
402+ }
399403 }
400404 break ;
401405 }
0 commit comments