File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ export const prettifyError =
9191 let count = 1
9292 const end = error . linePos [ 1 ]
9393 if ( end && end . line === line && end . col > col ) {
94- count = Math . min ( end . col - col , 80 - ci )
94+ count = Math . max ( 1 , Math . min ( end . col - col , 80 - ci ) )
9595 }
9696 const pointer = ' ' . repeat ( ci ) + '^' . repeat ( count )
9797 error . message += `:\n\n${ lineStr } \n${ pointer } \n`
Original file line number Diff line number Diff line change @@ -341,6 +341,12 @@ describe('pretty errors', () => {
341341 const doc = YAML . parseDocument ( src , { prettyErrors : true } )
342342 expect ( doc . warnings ) . toMatchObject ( [ { name : 'YAMLWarning' } ] )
343343 } )
344+
345+ test ( 'repeated CR' , ( ) => {
346+ const src = '[' + '\r' . repeat ( 80 )
347+ const doc = YAML . parseDocument ( src , { prettyErrors : true } )
348+ expect ( doc . errors [ 0 ] ) . not . toHaveProperty ( 'source' )
349+ } )
344350} )
345351
346352describe ( 'tags on invalid nodes' , ( ) => {
You can’t perform that action at this time.
0 commit comments