File tree 2 files changed +7
-1
lines changed
2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ export const prettifyError =
91
91
let count = 1
92
92
const end = error . linePos [ 1 ]
93
93
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 ) )
95
95
}
96
96
const pointer = ' ' . repeat ( ci ) + '^' . repeat ( count )
97
97
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', () => {
341
341
const doc = YAML . parseDocument ( src , { prettyErrors : true } )
342
342
expect ( doc . warnings ) . toMatchObject ( [ { name : 'YAMLWarning' } ] )
343
343
} )
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
+ } )
344
350
} )
345
351
346
352
describe ( 'tags on invalid nodes' , ( ) => {
You can’t perform that action at this time.
0 commit comments