Skip to content

Commit

Permalink
marginally better of stdout + stderr display
Browse files Browse the repository at this point in the history
bazel sends stdout and stderr separately, when in reality they are intertwined. if you put the stdout after the stderr, the next stderr batch can ssend control codes meant to wipe the stderr, but actually wipes the stderr. The downside of putting stdout first is that output can appear slightly out of order, but at least it won't get wiped.
  • Loading branch information
DolceTriade committed Jan 20, 2024
1 parent b4707b5 commit aab8ed5
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions blade/bep/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,13 @@ fn cleanup(orig: &str, stdout: &str, stderr: &str) -> String {
};
let clean_stdout = stdout.replace('\r', "");
let clean_stderr = stderr.replace('\r', "");
let out_lines = clean_stdout.split('\n');
let err_lines = clean_stderr.split('\n');
let mut lines = orig_lines
.into_iter()
.chain(out_lines)
.chain(err_lines)
.filter(|s| !s.is_empty())
.collect::<Vec<_>>();
let mut lines = orig_lines.into_iter().chain(err_lines).collect::<Vec<_>>();
let mut to_remove = vec![];
for (i, l) in lines.iter().enumerate().skip(orig_num_lines) {
if i == 0 {
continue;
}
let c = l.matches("\x1b[1A\x1b[K").count();
if c > 0 {
for j in 0..c {
to_remove.push(i - 1 - j);
}
for j in 0..c {
to_remove.push(i - 1 - j);
}
}

Expand All @@ -44,6 +33,7 @@ fn cleanup(orig: &str, stdout: &str, stderr: &str) -> String {
}
lines[i] = "";
}
lines.insert(orig_num_lines, &clean_stdout);
lines
.into_iter()
.filter(|s| !s.is_empty())
Expand Down

0 comments on commit aab8ed5

Please sign in to comment.