Skip to content

Commit f3bbba0

Browse files
committed
Revise integration based on Base.loaded_modules
1 parent 5adb626 commit f3bbba0

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/runner/PlutoRunner/src/evaluation/deleting globals.jl

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ function move_vars(
9595
end
9696

9797
do_reimports(new_workspace, module_imports_to_move)
98-
99-
invokelatest(revise_if_possible,new_workspace)
98+
revise_if_possible()
10099
end
101100

102101

@@ -219,16 +218,22 @@ else
219218
end
220219

221220

221+
const revise_pkg_id = Base.PkgId(UUID("295af30f-e4ad-537b-8983-00126c2a3abe"), "Revise")
222+
const revise_integration_broken = Ref(false)
222223

223-
224-
function revise_if_possible(m::Module)
225-
# Revise.jl support
226-
if isdefined(m, :Revise) &&
227-
isdefined(m.Revise, :revise) && m.Revise.revise isa Function &&
228-
isdefined(m.Revise, :revision_queue) && m.Revise.revision_queue isa AbstractSet
229-
230-
if !isempty(m.Revise.revision_queue) # to avoid the sleep(0.01) in revise()
231-
m.Revise.revise()
224+
# Revise.jl support
225+
function revise_if_possible()
226+
revise_integration_broken[] && return
227+
if haskey(Base.loaded_modules, revise_pkg_id)
228+
reviseee = Base.loaded_modules[revise_pkg_id]
229+
230+
try
231+
if !isempty(reviseee.revision_queue) # to avoid the sleep(0.01) in revise()
232+
reviseee.revise()
233+
end
234+
catch ex
235+
@warn "Failed to revise" exception=(ex, catch_backtrace()) pkgversion(reviseee)
236+
revise_integration_broken[] = true
232237
end
233238
end
234239
end

0 commit comments

Comments
 (0)