File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
crates/oxc_diagnostics/src Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -138,12 +138,17 @@ impl Info {
138138 if matches ! ( diagnostic. severity( ) , Some ( Severity :: Error ) ) {
139139 severity = Severity :: Error ;
140140 }
141- let msg = diagnostic. to_string ( ) ;
142141
143- // Our messages usually comes with `eslint(rule): message`
144- message = msg
145- . split_once ( ':' )
146- . map_or_else ( || msg. to_string ( ) , |( _, msg) | msg. trim ( ) . to_string ( ) ) ;
142+ message = diagnostic. to_string ( ) ;
143+ // Our messages usually are in format `eslint(rule): message`.
144+ // Trim off before the colon.
145+ if let Some ( ( _, msg) ) = message. split_once ( ':' ) {
146+ // Equivalent to `message = msg.trim().to_string()`, but operates in place
147+ let msg = msg. trim ( ) ;
148+ let start = msg. as_ptr ( ) as usize - message. as_str ( ) . as_ptr ( ) as usize ;
149+ message. truncate ( start + msg. len ( ) ) ;
150+ message. replace_range ( ..start, "" ) ;
151+ }
147152 }
148153 }
149154 }
You can’t perform that action at this time.
0 commit comments