File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -349,7 +349,7 @@ class SourceCode extends TokenStore {
349349 let currentToken = this . getTokenBefore ( node , { includeComments : true } ) ;
350350
351351 while ( currentToken && isCommentToken ( currentToken ) ) {
352- if ( node . parent && ( currentToken . start < node . parent . start ) ) {
352+ if ( node . parent && node . parent . type !== "Program" && ( currentToken . start < node . parent . start ) ) {
353353 break ;
354354 }
355355 comments . leading . push ( currentToken ) ;
@@ -361,7 +361,7 @@ class SourceCode extends TokenStore {
361361 currentToken = this . getTokenAfter ( node , { includeComments : true } ) ;
362362
363363 while ( currentToken && isCommentToken ( currentToken ) ) {
364- if ( node . parent && ( currentToken . end > node . parent . end ) ) {
364+ if ( node . parent && node . parent . type !== "Program" && ( currentToken . end > node . parent . end ) ) {
365365 break ;
366366 }
367367 comments . trailing . push ( currentToken ) ;
You can’t perform that action at this time.
0 commit comments