Skip to content

Commit

Permalink
interrupt the progress bar on error by adding \n (to stderr) so that …
Browse files Browse the repository at this point in the history
…the error message can be displayed on a new line (#2387)
  • Loading branch information
yihui committed Jan 9, 2025
1 parent 842e438 commit 45bb0f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion R/output.R
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,10 @@ process_file = function(text, output) {
res[i] = xfun:::handle_error(
withCallingHandlers(
if (tangle) process_tangle(group) else process_group(group),
error = function(e) if (xfun::pkg_available('rlang', '1.0.0')) rlang::entrace(e)
error = function(e) {
if (progress && is.function(pb$interrupt)) pb$interrupt()
if (xfun::pkg_available('rlang', '1.0.0')) rlang::entrace(e)
}
),
function(loc) {
setwd(wd)
Expand Down
1 change: 1 addition & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,7 @@ txt_pb = function(total, labels) {
setTxtProgressBar(pb, i)
cat_line(s[i]) # append chunk label to the progress bar
},
interrupt = function() message('\n'),
done = function() {
# wipe the progress bar
cat_line('\r', strrep(' ', max(w2, 10) + 10 + n))
Expand Down

0 comments on commit 45bb0f3

Please sign in to comment.