Skip to content

Commit

Permalink
Merge branch 'main' into cb/slider-server-status
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp authored Jul 20, 2023
2 parents 0a2af90 + 1d2c303 commit c6f0b67
Show file tree
Hide file tree
Showing 10 changed files with 462 additions and 163 deletions.
190 changes: 145 additions & 45 deletions frontend-bundler/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 17 additions & 11 deletions frontend/components/CellInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,17 +631,23 @@ export const CellInput = ({
// Remove selection on blur
EditorView.domEventHandlers({
blur: (event, view) => {
// collapse the selection into a single point
view.dispatch({
selection: {
anchor: view.state.selection.main.head,
},
scrollIntoView: false,
})
// and blur the DOM again (because the previous transaction might have re-focused it)
view.contentDOM.blur()

set_cm_forced_focus(null)
// it turns out that this condition is true *exactly* if and only if the blur event was triggered by blurring the window
let caused_by_window_blur = document.activeElement === view.contentDOM

if (!caused_by_window_blur) {
// then it's caused by focusing something other than this cell in the editor.
// in this case, we want to collapse the selection into a single point, for aesthetic reasons.
view.dispatch({
selection: {
anchor: view.state.selection.main.head,
},
scrollIntoView: false,
})
// and blur the DOM again (because the previous transaction might have re-focused it)
view.contentDOM.blur()

set_cm_forced_focus(null)
}
},
}),
pluto_paste_plugin({
Expand Down
1 change: 0 additions & 1 deletion frontend/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -3415,7 +3415,6 @@ pluto-cell.hooked_up pluto-output {
}

.pluto-frontmatter label {
text-transform: capitalize;
font-weight: 500;
}

Expand Down
18 changes: 10 additions & 8 deletions src/evaluation/Run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ function notebook_differences(from::Notebook, to::Notebook)
end
end,

folded_changed = any(from_cells[id].code_folded != to_cells[id].code_folded for id in keys(from_cells) if haskey(to_cells, id)),
order_changed = from.cell_order != to.cell_order,
nbpkg_changed = !is_nbpkg_equal(from.nbpkg_ctx, to.nbpkg_ctx),
)
Expand Down Expand Up @@ -555,16 +556,17 @@ function update_from_file(session::ServerSession, notebook::Notebook; kwargs...)
# @show added removed changed

cells_changed = !(isempty(added) && isempty(removed) && isempty(changed))
folded_changed = d.folded_changed
order_changed = d.order_changed
nbpkg_changed = d.nbpkg_changed

something_changed = cells_changed || order_changed || (include_nbpg && nbpkg_changed)
something_changed = cells_changed || folded_changed || order_changed || (include_nbpg && nbpkg_changed)

if something_changed
@info "Reloading notebook from file and applying changes!"
notebook.last_hot_reload_time = time()
end

for c in added
notebook.cells_dict[c] = just_loaded.cells_dict[c]
end
Expand All @@ -579,10 +581,10 @@ function update_from_file(session::ServerSession, notebook::Notebook; kwargs...)
for c in keys(notebook.cells_dict) keys(just_loaded.cells_dict)
notebook.cells_dict[c].code_folded = just_loaded.cells_dict[c].code_folded
end

notebook.cell_order = just_loaded.cell_order
notebook.metadata = just_loaded.metadata

if include_nbpg && nbpkg_changed
@info "nbpkgs not equal" (notebook.nbpkg_ctx isa Nothing) (just_loaded.nbpkg_ctx isa Nothing)

Expand All @@ -599,11 +601,11 @@ function update_from_file(session::ServerSession, notebook::Notebook; kwargs...)
end
notebook.nbpkg_restart_required_msg = "Yes, because the file was changed externally and the embedded Pkg changed."
end

if something_changed
update_save_run!(session, notebook, Cell[notebook.cells_dict[c] for c in union(added, changed)]; kwargs...) # this will also update nbpkg
update_save_run!(session, notebook, Cell[notebook.cells_dict[c] for c in union(added, changed)]; kwargs...) # this will also update nbpkg if needed
end

return true
end

Expand Down
Loading

0 comments on commit c6f0b67

Please sign in to comment.