@@ -232,51 +232,49 @@ with_progress <- function(expr, handlers = progressr::handlers(), cleanup = TRUE
232232
233233 # # Evaluate expression
234234 capture_conditions <- TRUE
235- res <- withVisible(
236- withCallingHandlers(
237- expr ,
238- progression = function (p ) {
239- # # Don't capture conditions that are produced by progression handlers
240- capture_conditions <<- FALSE
241- on.exit(capture_conditions <<- TRUE )
235+ res <- withCallingHandlers(
236+ withVisible(expr ),
237+ progression = function (p ) {
238+ # # Don't capture conditions that are produced by progression handlers
239+ capture_conditions <<- FALSE
240+ on.exit(capture_conditions <<- TRUE )
242241
243- # # Any buffered output to flush?
244- if (flush_terminal ) {
245- if (length(conditions ) > 0L || has_buffered_stdout(stdout_file )) {
246- calling_handler(control_progression(" hide" ))
247- stdout_file <<- flush_stdout(stdout_file , close = FALSE )
248- conditions <<- flush_conditions(conditions )
249- calling_handler(control_progression(" unhide" ))
250- }
242+ # # Any buffered output to flush?
243+ if (flush_terminal ) {
244+ if (length(conditions ) > 0L || has_buffered_stdout(stdout_file )) {
245+ calling_handler(control_progression(" hide" ))
246+ stdout_file <<- flush_stdout(stdout_file , close = FALSE )
247+ conditions <<- flush_conditions(conditions )
248+ calling_handler(control_progression(" unhide" ))
251249 }
250+ }
252251
253- calling_handler(p )
254- },
255- condition = function (c ) {
256- if (! capture_conditions || inherits(c , c(" progression" , " error" ))) return ()
257- if (inherits(c , delay_conditions )) {
258- # # Record
259- conditions [[length(conditions ) + 1L ]] <<- c
260- # # Muffle
261- if (inherits(c , " message" )) {
262- invokeRestart(" muffleMessage" )
263- } else if (inherits(c , " warning" )) {
264- invokeRestart(" muffleWarning" )
265- } else if (inherits(c , " condition" )) {
266- # # If there is a "muffle" restart for this condition,
267- # # then invoke that restart, i.e. "muffle" the condition
268- restarts <- computeRestarts(c )
269- for (restart in restarts ) {
270- name <- restart $ name
271- if (is.null(name )) next
272- if (! grepl(" ^muffle" , name )) next
273- invokeRestart(restart )
274- break
275- }
252+ calling_handler(p )
253+ },
254+ condition = function (c ) {
255+ if (! capture_conditions || inherits(c , c(" progression" , " error" ))) return ()
256+ if (inherits(c , delay_conditions )) {
257+ # # Record
258+ conditions [[length(conditions ) + 1L ]] <<- c
259+ # # Muffle
260+ if (inherits(c , " message" )) {
261+ invokeRestart(" muffleMessage" )
262+ } else if (inherits(c , " warning" )) {
263+ invokeRestart(" muffleWarning" )
264+ } else if (inherits(c , " condition" )) {
265+ # # If there is a "muffle" restart for this condition,
266+ # # then invoke that restart, i.e. "muffle" the condition
267+ restarts <- computeRestarts(c )
268+ for (restart in restarts ) {
269+ name <- restart $ name
270+ if (is.null(name )) next
271+ if (! grepl(" ^muffle" , name )) next
272+ invokeRestart(restart )
273+ break
276274 }
277275 }
278276 }
279- )
277+ }
280278 )
281279
282280 # # Success
0 commit comments