File tree 2 files changed +9
-8
lines changed 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,9 @@ 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( ) ) ;
@@ -185,11 +188,10 @@ fn format_maybe_source_line(
185
188
let end_column = end_column. unwrap ( ) ;
186
189
187
190
if start_column as usize >= source_line. len ( ) {
188
- eprintln ! (
189
- "{} Couldn't format source line: Column {} is out of bounds (source may have changed at runtime)" ,
191
+ return format ! (
192
+ "\n {} Couldn't format source line: Column {} is out of bounds (source may have changed at runtime)" ,
190
193
crate :: colors:: yellow( "Warning" ) , start_column + 1 ,
191
194
) ;
192
- return "" . to_string ( ) ;
193
195
}
194
196
195
197
// TypeScript uses `~` always, but V8 would utilise `^` always, even when
Original file line number Diff line number Diff line change @@ -618,18 +618,17 @@ impl SourceMapGetter for ProcState {
618
618
line_number : usize ,
619
619
) -> Option < String > {
620
620
if let Ok ( specifier) = resolve_url ( file_name) {
621
- self . file_fetcher . get_source ( & specifier) . and_then ( |out| {
621
+ self . file_fetcher . get_source ( & specifier) . map ( |out| {
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
625
if line_number >= lines. len ( ) {
626
- eprintln ! (
626
+ format ! (
627
627
"{} Couldn't format source line: Line {} is out of bounds (source may have changed at runtime)" ,
628
628
crate :: colors:: yellow( "Warning" ) , line_number + 1 ,
629
- ) ;
630
- None
629
+ )
631
630
} else {
632
- Some ( lines[ line_number] . to_string ( ) )
631
+ lines[ line_number] . to_string ( )
633
632
}
634
633
} )
635
634
} else {
You can’t perform that action at this time.
0 commit comments