vscode julia path changed, code to avoid Main.Notebook module context changed
This commit is contained in:
@@ -9,10 +9,23 @@ julia:
|
||||
#| echo: false
|
||||
#| output: false
|
||||
using InteractiveUtils
|
||||
import QuartoNotebookWorker
|
||||
Base.stdout = QuartoNotebookWorker.with_context(stdout)
|
||||
myactive_module() = Main.Notebook
|
||||
Base.active_module() = myactive_module()
|
||||
|
||||
#struct M a::Int end; x = M(22); @show x
|
||||
#should not print "Main.Notebook.M(22)" but only "M(22)"
|
||||
function Base.show(io::IO, x::T) where T
|
||||
if parentmodule(T) == @__MODULE__
|
||||
# Print "TypeName(fields...)" without module prefix
|
||||
print(io, nameof(T), "(")
|
||||
fields = fieldnames(T)
|
||||
for (i, f) in enumerate(fields)
|
||||
print(io, getfield(x, f))
|
||||
i < length(fields) && print(io, ", ")
|
||||
end
|
||||
print(io, ")")
|
||||
else
|
||||
invoke(Base.show, Tuple{IO, Any}, io, x)
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
# Working with Julia: The REPL, Packages, and Introspection
|
||||
|
||||
Reference in New Issue
Block a user