Skip to content

Commit

Permalink
unlock opts_current before restoring it
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Aug 30, 2023
1 parent 7cd115a commit 3245aab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion R/block.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ call_block = function(block) {
}

# save current chunk options in opts_current
opts_current$restore(params)
opts_current$unlock(); opts_current$restore(params)

if (opts_knit$get('progress')) print(block)

Expand Down
11 changes: 7 additions & 4 deletions R/output.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,13 @@ knit = function(
)
on.exit(options(oopts), add = TRUE)
# restore chunk options after parent exits
optc = opts_chunk$get(); on.exit(opts_chunk$restore(optc), add = TRUE)
ocode = knit_code$get(); on.exit(knit_code$restore(ocode), add = TRUE)
on.exit(opts_current$restore(), add = TRUE)
optk = opts_knit$get(); on.exit(opts_knit$restore(optk), add = TRUE)
optc = opts_chunk$get(); ocode = knit_code$get(); optk = opts_knit$get()
on.exit({
opts_chunk$restore(optc)
knit_code$restore(ocode)
opts_current$unlock(); opts_current$restore()
opts_knit$restore(optk)
}, add = TRUE)
opts_knit$set(
output.dir = getwd(), # record working directory in 1st run
tangle = tangle, progress = opts_knit$get('progress') && !quiet
Expand Down

0 comments on commit 3245aab

Please sign in to comment.