Skip to content

Commit 197ab24

Browse files
committed
Revert "Trigger namespace resource from browser() too"
This reverts commit e8bf1a9.
1 parent 1963e4a commit 197ab24

File tree

2 files changed

+6
-67
lines changed

2 files changed

+6
-67
lines changed

crates/ark/src/modules/positron/hooks.R

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,9 @@
66
#
77

88
register_hooks <- function() {
9-
rebind(
10-
"utils",
11-
"View",
12-
.ps.view_data_frame,
13-
namespace = TRUE
14-
)
15-
rebind(
16-
"base",
17-
"debug",
18-
new_ark_debug(base::debug),
19-
namespace = TRUE
20-
)
21-
rebind(
22-
"base",
23-
"debugonce",
24-
new_ark_debug(base::debugonce),
25-
namespace = TRUE
26-
)
27-
rebind(
28-
"base",
29-
"browser",
30-
new_ark_browser(base::browser),
31-
namespace = TRUE
32-
)
9+
rebind("utils", "View", .ps.view_data_frame, namespace = TRUE)
10+
rebind("base", "debug", new_ark_debug(base::debug), namespace = TRUE)
11+
rebind("base", "debugonce", new_ark_debug(base::debugonce), namespace = TRUE)
3312
register_getHook_hook()
3413
}
3514

@@ -45,7 +24,7 @@ rebind <- function(pkg, name, value, namespace = FALSE) {
4524
pkg = pkg,
4625
name = name,
4726
value = value
48-
)
27+
)
4928
}
5029
}
5130

@@ -63,11 +42,7 @@ pkg_bind <- function(pkg, name, value) {
6342
env <- as.environment(env)
6443

6544
if (!exists(name, envir = env, mode = "function", inherits = FALSE)) {
66-
msg <- sprintf(
67-
"Can't register hook: function `%s::%s` not found.",
68-
pkg,
69-
name
70-
)
45+
msg <- sprintf("Can't register hook: function `%s::%s` not found.", pkg, name)
7146
stop(msg, call. = FALSE)
7247
}
7348

@@ -95,12 +70,7 @@ register_getHook_hook <- function() {
9570
local_unlock_binding(ns, "getHook")
9671

9772
ns[["getHook"]] <- function(hookName, ...) {
98-
hooks <- get0(
99-
hookName,
100-
envir = .userHooksEnv,
101-
inherits = FALSE,
102-
ifnotfound = list()
103-
)
73+
hooks <- get0(hookName, envir = .userHooksEnv, inherits = FALSE, ifnotfound = list())
10474

10575
if (!grepl("^UserHook::.*::onLoad$", hookName)) {
10676
return(hooks)

crates/ark/src/modules/positron/srcref.R

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -76,37 +76,6 @@ new_ark_debug <- function(fn) {
7676
fn
7777
}
7878

79-
new_ark_browser <- function(fn) {
80-
browser <- base::browser
81-
82-
function(text = "", condition = NULL, expr = TRUE, skipCalls = 0L) {
83-
local({
84-
if (!.ps.internal(do_resource_namespaces(default = TRUE))) {
85-
return() # from local()
86-
}
87-
88-
pkgs <- loadedNamespaces()
89-
90-
# Give priority to the namespace of the calling function
91-
env <- topenv(parent.frame())
92-
if (isNamespace(env)) {
93-
pkgs <- unique(c(getNamespaceName(env), pkgs))
94-
}
95-
96-
# Enable namespace resourcing for all future loaded namespaces and
97-
# resource already loaded namespaces so we get virtual documents for
98-
# step-debugging.
99-
options(ark.resource_namespaces = TRUE)
100-
.ps.internal(resource_loaded_namespaces(pkgs))
101-
})
102-
103-
# Skip this wrapper
104-
skipCalls <- skipCalls + 1L
105-
106-
browser(text = text, condition = condition, expr = expr, skipCalls = skipCalls)
107-
}
108-
}
109-
11079
do_resource_namespaces <- function(default) {
11180
getOption("ark.resource_namespaces", default = default)
11281
}

0 commit comments

Comments
 (0)