File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -234,15 +234,29 @@ export function fitSpans(
234
234
export function findFrontChar ( regex : RegExp , index : number , text : string ) {
235
235
let i = index ;
236
236
while ( ! regex . test ( text [ i ] ) ) {
237
- i -- ;
237
+ // istanbul ignore next
238
+ if ( -- i < 0 ) {
239
+ throw new Error (
240
+ `Cannot find front char ${ regex } from index ${ index } in ${ JSON . stringify (
241
+ text ,
242
+ ) } `,
243
+ ) ;
244
+ }
238
245
}
239
246
return i ;
240
247
}
241
248
242
249
export function findBackChar ( regex : RegExp , index : number , text : string ) {
243
250
let i = index ;
244
251
while ( ! regex . test ( text [ i ] ) ) {
245
- i ++ ;
252
+ // istanbul ignore next
253
+ if ( ++ i >= text . length ) {
254
+ throw new Error (
255
+ `Cannot find back char ${ regex } from index ${ index } in ${ JSON . stringify (
256
+ text ,
257
+ ) } `,
258
+ ) ;
259
+ }
246
260
}
247
261
return i ;
248
262
}
You can’t perform that action at this time.
0 commit comments