File tree 2 files changed +19
-2
lines changed 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -177,12 +177,23 @@ fn format_maybe_source_line(
177
177
if source_line. is_empty ( ) || source_line. len ( ) > SOURCE_ABBREV_THRESHOLD {
178
178
return "" . to_string ( ) ;
179
179
}
180
+ if source_line. contains ( "Couldn't format source line: " ) {
181
+ return format ! ( "\n {}" , source_line) ;
182
+ }
180
183
181
184
assert ! ( start_column. is_some( ) ) ;
182
185
assert ! ( end_column. is_some( ) ) ;
183
186
let mut s = String :: new ( ) ;
184
187
let start_column = start_column. unwrap ( ) ;
185
188
let end_column = end_column. unwrap ( ) ;
189
+
190
+ if start_column as usize >= source_line. len ( ) {
191
+ return format ! (
192
+ "\n {} Couldn't format source line: Column {} is out of bounds (source may have changed at runtime)" ,
193
+ crate :: colors:: yellow( "Warning" ) , start_column + 1 ,
194
+ ) ;
195
+ }
196
+
186
197
// TypeScript uses `~` always, but V8 would utilise `^` always, even when
187
198
// doing ranges, so here, if we only have one marker (very common with V8
188
199
// errors) we will use `^` instead.
Original file line number Diff line number Diff line change @@ -622,8 +622,14 @@ impl SourceMapGetter for ProcState {
622
622
// Do NOT use .lines(): it skips the terminating empty line.
623
623
// (due to internally using .split_terminator() instead of .split())
624
624
let lines: Vec < & str > = out. source . split ( '\n' ) . collect ( ) ;
625
- assert ! ( lines. len( ) > line_number) ;
626
- lines[ line_number] . to_string ( )
625
+ if line_number >= lines. len ( ) {
626
+ format ! (
627
+ "{} Couldn't format source line: Line {} is out of bounds (source may have changed at runtime)" ,
628
+ crate :: colors:: yellow( "Warning" ) , line_number + 1 ,
629
+ )
630
+ } else {
631
+ lines[ line_number] . to_string ( )
632
+ }
627
633
} )
628
634
} else {
629
635
None
You can’t perform that action at this time.
0 commit comments