Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use bindingIsActive #1031

Merged
merged 1 commit into from
Mar 10, 2022
Merged

Conversation

renkun-ken
Copy link
Member

@renkun-ken renkun-ken commented Mar 10, 2022

What problem did you solve?

Related: #1030

This PR uses bindingIsActive(sym, env) to check if a symbol is active binding. It is a walk around of rlang::env_binding_are_active when base already does it.

(If you have)Screenshot

(If you do not have screenshot) How can I check this pull request?

makeActiveBinding("x", function() {
  cat("x\n")
  runif(1)
}, globalenv())

Run other commands and see if the workspace viewer correctly shows x as an active binding.

env <- local({
  makeActiveBinding("x", function() {
    cat("x\n")
    runif(1)
  }, environment())
  environment()
})
View(env)

@MilesMcBain
Copy link
Collaborator

Does this still have an issue since rlang::env_binding_are_lazy(env, all_names) will evaluate the active bindings also?

@renkun-ken
Copy link
Member Author

Yes, rlang::env_binding_are_lazy(env, all_names) still will evaluate active bindings. So this PR does not resolve the problem but only replaces rlang function with base when possible.

@renkun-ken renkun-ken merged commit 91e9c06 into REditorSupport:master Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants