File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
apps/oxlint/src-js/plugins Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,9 @@ let sourceByteLen: number = 0;
3535let ast : Program | null = null ;
3636
3737// Lazily populated when `SOURCE_CODE.lines` is accessed.
38+ // `lineStartOffsets` starts as `[0]`, and `resetSource` doesn't remove that initial element, so it's never empty.
3839const lines : string [ ] = [ ] ,
39- lineStartOffsets : number [ ] = [ ] ;
40+ lineStartOffsets : number [ ] = [ 0 ] ;
4041
4142// Lazily populated when `SOURCE_CODE.visitorKeys` is accessed.
4243let visitorKeys : { [ key : string ] : string [ ] } | null = null ;
@@ -101,7 +102,7 @@ function initLines(): void {
101102 * and uses match.index to get the correct line start indices.
102103 */
103104
104- lineStartOffsets . push ( 0 ) ;
105+ // Note: ` lineStartOffsets` starts as `[0]`
105106 let lastOffset = 0 , offset , match ;
106107 while ( ( match = LINE_BREAK_PATTERN . exec ( sourceText ) ) ) {
107108 offset = match . index ;
@@ -126,7 +127,7 @@ export function resetSource(): void {
126127 sourceText = null ;
127128 ast = null ;
128129 lines . length = 0 ;
129- lineStartOffsets . length = 0 ;
130+ lineStartOffsets . length = 1 ;
130131}
131132
132133// `SourceCode` object.
You can’t perform that action at this time.
0 commit comments