diff --git a/Project.toml b/Project.toml index a1c8793713..96761fc14a 100644 --- a/Project.toml +++ b/Project.toml @@ -2,7 +2,7 @@ name = "Pluto" uuid = "c3e4b0f8-55cb-11ea-2926-15256bba5781" license = "MIT" authors = ["Fons van der Plas "] -version = "0.12.14" +version = "0.12.15" [deps] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/frontend/components/LiveDocs.js b/frontend/components/LiveDocs.js index b2e76994b8..1ed606039c 100644 --- a/frontend/components/LiveDocs.js +++ b/frontend/components/LiveDocs.js @@ -105,7 +105,7 @@ export let LiveDocs = ({ desired_doc_query, client, on_update_doc_query, noteboo ? "Live docs" : html` header > input { border: none; } pluto-helpbox.notfound > header > input { - color: red; + color: rgb(139, 139, 139); } pluto-helpbox > header > input:focus { outline: none; diff --git a/src/runner/PlutoRunner.jl b/src/runner/PlutoRunner.jl index 1ede12ae83..2655ec5a51 100644 --- a/src/runner/PlutoRunner.jl +++ b/src/runner/PlutoRunner.jl @@ -84,12 +84,15 @@ struct Computer output_globals::Vector{Symbol} end +expr_hash(e::Expr) = objectid(e.head) + mapreduce(expr_hash, +, e.args; init=zero(ObjectID)) +expr_hash(x) = objectid(x) # TODO: clear key when a cell is deleted furever -const computers = Dict{Expr,Computer}() +const computers = Dict{ObjectID,Computer}() const computer_workspace = Main -function register_computer(expr::Expr, input_globals::Vector{Symbol}, output_globals::Vector{Symbol}) + +function register_computer(expr::Expr, key, input_globals::Vector{Symbol}, output_globals::Vector{Symbol}) proof = ReturnProof() @gensym result @@ -103,7 +106,7 @@ function register_computer(expr::Expr, input_globals::Vector{Symbol}, output_glo f = Core.eval(computer_workspace, e) - computers[expr] = Computer(f, proof, input_globals, output_globals) + computers[key] = Computer(f, proof, input_globals, output_globals) end function compute(computer::Computer) @@ -190,10 +193,11 @@ function run_expression(expr::Any, cell_id::UUID, function_wrapped_info::Union{N wrapped = timed_expr(expr, proof) run_inside_trycatch(wrapped, cell_id, proof) else - local computer = get(computers, expr, nothing) + key = expr_hash(expr) + local computer = get(computers, key, nothing) if computer === nothing try - computer = register_computer(expr, collect.(function_wrapped_info)...) + computer = register_computer(expr, key, collect.(function_wrapped_info)...) catch e # @error "Failed to generate computer function" expr exception=(e,stacktrace(catch_backtrace())) return run_expression(expr, cell_id, nothing) diff --git a/test/React.jl b/test/React.jl index 93267e91d6..2de876885c 100644 --- a/test/React.jl +++ b/test/React.jl @@ -861,6 +861,8 @@ import Distributed false end |> length """), + Cell("4"), + Cell("[5]"), ]) update_run!(🍭, notebook, notebook.cells) @@ -885,6 +887,16 @@ import Distributed update_run!(🍭, notebook, notebook.cells) @test 0.2 * good < notebook.cells[3].runtime / 1.0e9 < 1.5 * bad + old = notebook.cells[4].output_repr + setcode(notebook.cells[4], "4.0") + update_run!(🍭, notebook, notebook.cells[4]) + @test old != notebook.cells[4].output_repr + + old = notebook.cells[5].output_repr + setcode(notebook.cells[5], "[5.0]") + update_run!(🍭, notebook, notebook.cells[5]) + @test old != notebook.cells[5].output_repr + WorkspaceManager.unmake_workspace((🍭, notebook)) end diff --git a/test/RichOutput.jl b/test/RichOutput.jl index c2ffc13a39..2bd1158d0a 100644 --- a/test/RichOutput.jl +++ b/test/RichOutput.jl @@ -141,11 +141,11 @@ import Pluto: update_run!, WorkspaceManager, ClientSession, ServerSession, Noteb Cell("DataFrame()"), Cell("DataFrame(:a => [])"), Cell("DataFrame(:a => [1,2,3], :b => [999, 5, 6])"), - Cell("DataFrame(rand(20,20))"), - Cell("DataFrame(rand(2000,20))"), - Cell("DataFrame(rand(20,2000))"), - Cell("@view DataFrame(rand(100,3))[:, 2:2]"), - Cell("@view DataFrame(rand(3,100))[2:2, :]"), + Cell("DataFrame(rand(20,20), :auto)"), + Cell("DataFrame(rand(2000,20), :auto)"), + Cell("DataFrame(rand(20,2000), :auto)"), + Cell("@view DataFrame(rand(100,3), :auto)[:, 2:2]"), + Cell("@view DataFrame(rand(3,100), :auto)[2:2, :]"), Cell("DataFrame"), Cell("Tables.table(rand(11,11))"), Cell("Tables.table(rand(120,120))"),