@@ -370,6 +370,24 @@ fn original_position_glb_index(line_mappings: &[Mapping], column: u32) -> Option
370370 }
371371}
372372
373+ fn original_position_lub_index ( line_mappings : & [ Mapping ] , column : u32 ) -> Option < usize > {
374+ match line_mappings. binary_search_by_key ( & column, |m| m. generated_column ) {
375+ // Exact match: walk forward to the latest segment sharing this column.
376+ // Mirrors `@jridgewell/trace-mapping`'s LUB = latest-equal tie-break.
377+ Ok ( i) => {
378+ let mut idx = i;
379+ while idx + 1 < line_mappings. len ( )
380+ && line_mappings[ idx + 1 ] . generated_column == column
381+ {
382+ idx += 1 ;
383+ }
384+ Some ( idx)
385+ }
386+ Err ( i) if i >= line_mappings. len ( ) => None ,
387+ Err ( i) => Some ( i) ,
388+ }
389+ }
390+
373391fn generated_only_mapping ( line : u32 , generated_column : i64 ) -> Mapping {
374392 Mapping {
375393 generated_line : line,
@@ -1010,27 +1028,7 @@ impl SourceMap {
10101028 Some ( idx) => idx,
10111029 None => return self . range_mapping_fallback ( line, column) ,
10121030 } ,
1013- Bias :: LeastUpperBound => {
1014- match line_mappings. binary_search_by_key ( & column, |m| m. generated_column ) {
1015- // Exact match: walk forward to the latest segment sharing this column.
1016- // Mirrors `@jridgewell/trace-mapping`'s LUB = latest-equal tie-break.
1017- Ok ( i) => {
1018- let mut idx = i;
1019- while idx + 1 < line_mappings. len ( )
1020- && line_mappings[ idx + 1 ] . generated_column == column
1021- {
1022- idx += 1 ;
1023- }
1024- idx
1025- }
1026- Err ( i) => {
1027- if i >= line_mappings. len ( ) {
1028- return None ;
1029- }
1030- i
1031- }
1032- }
1033- }
1031+ Bias :: LeastUpperBound => original_position_lub_index ( line_mappings, column) ?,
10341032 } ;
10351033
10361034 let mapping = & line_mappings[ idx] ;
0 commit comments