@@ -1078,17 +1078,14 @@ impl EmitterWriter {
10781078
10791079 let suggestions = suggestion. splice_lines ( cm. borrow ( ) ) ;
10801080 let span_start_pos = cm. lookup_char_pos ( primary_sub. span . lo ) ;
1081- let span_end_pos = cm. lookup_char_pos ( primary_sub. span . hi ) ;
10821081 let line_start = span_start_pos. line ;
10831082 draw_col_separator_no_space ( & mut buffer, 1 , max_line_num_len + 1 ) ;
10841083 let mut row_num = 2 ;
1085- for complete in suggestions. iter ( ) . take ( MAX_SUGGESTIONS ) {
1084+ for ( & ( ref complete, show_underline) , ref sub) in suggestions
1085+ . iter ( ) . zip ( primary_sub. substitutions . iter ( ) ) . take ( MAX_SUGGESTIONS )
1086+ {
10861087 let mut line_pos = 0 ;
10871088 // Only show underline if there's a single suggestion and it is a single line
1088- let show_underline = complete. lines ( ) . count ( ) == 1
1089- && span_start_pos. line == span_end_pos. line
1090- && primary_sub. substitutions . len ( ) == 1 ;
1091-
10921089 let mut lines = complete. lines ( ) ;
10931090 for line in lines. by_ref ( ) . take ( MAX_HIGHLIGHT_LINES ) {
10941091 // Print the span column to avoid confusion
@@ -1099,11 +1096,13 @@ impl EmitterWriter {
10991096 // print the suggestion
11001097 draw_col_separator ( & mut buffer, row_num, max_line_num_len + 1 ) ;
11011098 buffer. append ( row_num, line, Style :: NoStyle ) ;
1099+ line_pos += 1 ;
11021100 row_num += 1 ;
1101+ // Only show an underline in the suggestions if the suggestion is not the
1102+ // entirety of the code being shown and the displayed code is not multiline.
11031103 if show_underline {
11041104 draw_col_separator ( & mut buffer, row_num, max_line_num_len + 1 ) ;
1105-
1106- let sub_len = primary_sub. substitutions [ 0 ] . trim_right ( ) . len ( ) ;
1105+ let sub_len = sub. trim_right ( ) . len ( ) ;
11071106 let underline_start = span_start_pos. col . 0 ;
11081107 let underline_end = span_start_pos. col . 0 + sub_len;
11091108 for p in underline_start..underline_end {
@@ -1114,19 +1113,19 @@ impl EmitterWriter {
11141113 }
11151114 row_num += 1 ;
11161115 }
1117- line_pos += 1 ;
11181116 }
11191117
11201118 // if we elided some lines, add an ellipsis
11211119 if let Some ( _) = lines. next ( ) {
1122- buffer. append ( row_num, "..." , Style :: NoStyle ) ;
1123- } else if !show_underline && suggestions . len ( ) <= MAX_SUGGESTIONS {
1120+ buffer. puts ( row_num, max_line_num_len - 1 , "..." , Style :: LineNumber ) ;
1121+ } else if !show_underline {
11241122 draw_col_separator_no_space ( & mut buffer, row_num, max_line_num_len + 1 ) ;
1123+ row_num += 1 ;
11251124 }
11261125 }
11271126 if suggestions. len ( ) > MAX_SUGGESTIONS {
11281127 let msg = format ! ( "and {} other candidates" , suggestions. len( ) - MAX_SUGGESTIONS ) ;
1129- buffer. append ( row_num, & msg, Style :: NoStyle ) ;
1128+ buffer. puts ( row_num, 0 , & msg, Style :: NoStyle ) ;
11301129 }
11311130 emit_to_destination ( & buffer. render ( ) , level, & mut self . dst ) ?;
11321131 }
0 commit comments