Skip to content

Commit 04ab409

Browse files
BUG FIX: with_progress(..., delay_conditions = "condition") would also capture progress::progress_bar() output [#50]
1 parent 5c42853 commit 04ab409

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ NEW FEATURES:
1212

1313
* Added print() for 'progression_handler' objects.
1414

15+
BUG FIXES:
16+
17+
* with_progress(..., delay_conditions = "condition"), introduced in v0.1.0,
18+
would also capture conditions produced by progression handlers, e.g.
19+
progress::progress_bar() output would not be displayed until the very end.
20+
1521

1622
Version: 0.1.1 [2019-06-08]
1723

R/with_progress.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,17 @@ with_progress <- function(expr, handlers = getOption("progressr.handlers", txtpr
129129
}, progression = handler)
130130

131131
## Evaluate expression
132+
capture_conditions <- TRUE
132133
withCallingHandlers(
133134
expr,
134-
progression = handler,
135+
progression = function(p) {
136+
## Don't capture conditions that are produced by progression handlers
137+
capture_conditions <<- FALSE
138+
on.exit(capture_conditions <<- TRUE)
139+
handler(p)
140+
},
135141
condition = function(c) {
136-
if (inherits(c, c("progression", "error"))) return()
142+
if (!capture_conditions || inherits(c, c("progression", "error"))) return()
137143
if (inherits(c, delay_conditions)) {
138144
## Record
139145
conditions[[length(conditions) + 1L]] <<- c

0 commit comments

Comments
 (0)