Skip to content

Commit 1ddfd15

Browse files
Few updates
1 parent 390241e commit 1ddfd15

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/librustc_driver/lib.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,19 +286,20 @@ fn get_color(color: Color, style: Style, text: &str) -> String {
286286
fn parse_input(input: &str) -> String {
287287
let lines : Vec<&str> = input.split('\n').collect();
288288
let mut out = String::new();
289+
let mut total = lines.len();
289290

290291
for line in lines {
292+
if line.starts_with("#") {
293+
out.push_str(&get_color(Color::White, Style::NoStyle, line));
294+
out.push('\n');
295+
continue;
296+
}
291297
let words : Vec<&str> = line.split(' ').collect();
292298
let mut it = 0;
293299

294300
while it < words.len() {
295301
let word : &str = words[it];
296302

297-
if word.starts_with("#") {
298-
out.push_str(&get_color(Color::White, Style::NoStyle, word));
299-
it += 1;
300-
continue;
301-
}
302303
match word {
303304
"pub" | "const" | "static" | "crate" | "extern" => {
304305
out.push_str(&get_color(Color::Red, Style::NoStyle, word));
@@ -368,7 +369,10 @@ fn parse_input(input: &str) -> String {
368369
out.push(' ');
369370
}
370371
}
371-
out.push('\n');
372+
total -= 1;
373+
if total > 1 {
374+
out.push('\n');
375+
}
372376
}
373377
out
374378
}

0 commit comments

Comments
 (0)