@@ -325,14 +325,46 @@ impl DiagnosticMessage {
325325 if !has_ariadne {
326326 // No ariadne - show everything in tidyverse style
327327
328- // Title with kind prefix (e.g., "Error: Invalid input")
328+ // Title with kind prefix and error code (e.g., "Error [Q-1-1] : Invalid input")
329329 let kind_str = match self . kind {
330330 DiagnosticKind :: Error => "Error" ,
331331 DiagnosticKind :: Warning => "Warning" ,
332332 DiagnosticKind :: Info => "Info" ,
333333 DiagnosticKind :: Note => "Note" ,
334334 } ;
335- write ! ( result, "{}: {}\n " , kind_str, self . title) . unwrap ( ) ;
335+ if let Some ( code) = & self . code {
336+ write ! ( result, "{} [{}]: {}\n " , kind_str, code, self . title) . unwrap ( ) ;
337+ } else {
338+ write ! ( result, "{}: {}\n " , kind_str, self . title) . unwrap ( ) ;
339+ }
340+
341+ // Show location info if available (but no ariadne rendering)
342+ if let Some ( loc) = & self . location {
343+ // Try to map with context if available
344+ if let Some ( ctx) = ctx {
345+ if let Some ( mapped) = loc. map_offset ( loc. range . start . offset , ctx) {
346+ if let Some ( file) = ctx. get_file ( mapped. file_id ) {
347+ write ! (
348+ result,
349+ " at {}:{}:{}\n " ,
350+ file. path,
351+ mapped. location. row + 1 ,
352+ mapped. location. column + 1
353+ )
354+ . unwrap ( ) ;
355+ }
356+ }
357+ } else {
358+ // No context: show immediate location (1-indexed for display)
359+ write ! (
360+ result,
361+ " at {}:{}\n " ,
362+ loc. range. start. row + 1 ,
363+ loc. range. start. column + 1
364+ )
365+ . unwrap ( ) ;
366+ }
367+ }
336368
337369 // Problem statement (optional additional context)
338370 if let Some ( problem) = & self . problem {
@@ -651,13 +683,13 @@ mod tests {
651683 #[ test]
652684 fn test_to_text_simple_error ( ) {
653685 let msg = DiagnosticMessage :: error ( "Something went wrong" ) ;
654- assert_eq ! ( msg. to_text( None ) , "Error: Something went wrong" ) ;
686+ assert_eq ! ( msg. to_text( None ) , "Error: Something went wrong\n " ) ;
655687 }
656688
657689 #[ test]
658690 fn test_to_text_with_code ( ) {
659691 let msg = DiagnosticMessage :: error ( "Something went wrong" ) . with_code ( "Q-1-1" ) ;
660- assert_eq ! ( msg. to_text( None ) , "Error [Q-1-1]: Something went wrong" ) ;
692+ assert_eq ! ( msg. to_text( None ) , "Error [Q-1-1]: Something went wrong\n " ) ;
661693 }
662694
663695 #[ test]
0 commit comments