@@ -143,7 +143,7 @@ const forEachMapping = (mappings, onSegment) => {
143143 * far into it the map reaches. Both lines are counted from zero, so a caller
144144 * whose lines start at one subtracts before feeding a segment in.
145145 * @param {number= } sourceCount number of entries in the map's `sources`, when known
146- * @returns {{ add: (generatedLine: number, generatedColumn: number, sourceIndex: number, originalLine: number) => void, finish: (lastLine: number) => SourceScope[] } } collector
146+ * @returns {{ add: (generatedLine: number, generatedColumn: number, sourceIndex: number, originalLine: number) => void, finish: (lastLine: number, lastColumn?: number ) => SourceScope[] } } collector
147147 */
148148const createScopeCollector = ( sourceCount ) => {
149149 /** @type {Map<number, SourceScope> } */
@@ -201,8 +201,8 @@ const createScopeCollector = (sourceCount) => {
201201 openScope = scope ;
202202 openSource = sourceIndex ;
203203 } ,
204- finish ( lastLine ) {
205- closeRun ( lastLine , 0 ) ;
204+ finish ( lastLine , lastColumn = 0 ) {
205+ closeRun ( lastLine , lastColumn ) ;
206206 return [ ...scopes . values ( ) ] . sort ( ( a , b ) => a . sourceIndex - b . sourceIndex ) ;
207207 } ,
208208 } ;
@@ -389,8 +389,9 @@ const addScopesToSourceMap = (sourceMap, getBindings) => {
389389/**
390390 * Builds the `scopes` field while a map is being written, so the segments are
391391 * read as they are produced rather than decoded back out of `mappings`. Lines
392- * are the one-based ones the chunk stream reports.
393- * @returns {{ add: (generatedLine: number, generatedColumn: number, sourceIndex: number, originalLine: number) => void, addSource: (sourceIndex: number, scopeBindings?: ScopeBindings) => void, finish: (map: RawSourceMap, generatedLine: number) => void } } writer
392+ * are the one-based ones the chunk stream reports; `finish` takes the position
393+ * the generated code ends at, where the last range closes.
394+ * @returns {{ add: (generatedLine: number, generatedColumn: number, sourceIndex: number, originalLine: number) => void, addSource: (sourceIndex: number, scopeBindings?: ScopeBindings) => void, finish: (map: RawSourceMap, generatedLine: number, generatedColumn?: number) => void } } writer
394395 */
395396const createScopesWriter = ( ) => {
396397 const collector = createScopeCollector ( ) ;
@@ -410,9 +411,9 @@ const createScopesWriter = () => {
410411 bindingsBySource . set ( sourceIndex , scopeBindings ) ;
411412 }
412413 } ,
413- finish ( map , generatedLine ) {
414+ finish ( map , generatedLine , generatedColumn = 0 ) {
414415 if ( bindingsBySource . size === 0 ) return ;
415- const scopes = collector . finish ( generatedLine - 1 ) ;
416+ const scopes = collector . finish ( generatedLine - 1 , generatedColumn ) ;
416417 let any = false ;
417418 for ( const scope of scopes ) {
418419 const bindings = bindingsBySource . get ( scope . sourceIndex ) ;
0 commit comments