Skip to content

Commit 45bb0f3

Browse files
committed
interrupt the progress bar on error by adding \n (to stderr) so that the error message can be displayed on a new line (#2387)
1 parent 842e438 commit 45bb0f3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

R/output.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,10 @@ process_file = function(text, output) {
311311
res[i] = xfun:::handle_error(
312312
withCallingHandlers(
313313
if (tangle) process_tangle(group) else process_group(group),
314-
error = function(e) if (xfun::pkg_available('rlang', '1.0.0')) rlang::entrace(e)
314+
error = function(e) {
315+
if (progress && is.function(pb$interrupt)) pb$interrupt()
316+
if (xfun::pkg_available('rlang', '1.0.0')) rlang::entrace(e)
317+
}
315318
),
316319
function(loc) {
317320
setwd(wd)

R/utils.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,7 @@ txt_pb = function(total, labels) {
11361136
setTxtProgressBar(pb, i)
11371137
cat_line(s[i]) # append chunk label to the progress bar
11381138
},
1139+
interrupt = function() message('\n'),
11391140
done = function() {
11401141
# wipe the progress bar
11411142
cat_line('\r', strrep(' ', max(w2, 10) + 10 + n))

0 commit comments

Comments
 (0)