Skip to content

Commit

Permalink
Fix Cmd+Click behaviour on local variables
Browse files Browse the repository at this point in the history
Continued from #2452
  • Loading branch information
fonsp committed Jan 26, 2023
1 parent 17da71b commit 469b82b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions frontend/components/CellInput/go_to_definition_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,16 @@ export const go_to_definition_plugin = ViewPlugin.fromClass(
let variable_from = Number(cell_variable.getAttribute("data-cell-variable-from"))
let variable_to = Number(cell_variable.getAttribute("data-cell-variable-to"))

if (variable_name == null || variable_from == null || variable_to == null) {
return false
}

if (!(has_ctrl_or_cmd_pressed(event) || view.state.readOnly)) {
return false
}

event.preventDefault()

view.dispatch({
scrollIntoView: true,
selection: { anchor: variable_from, head: variable_to },
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ patch: ${JSON.stringify(
const set_ctrl_down = (value) => {
if (value !== ctrl_down_last_val.current) {
ctrl_down_last_val.current = value
document.body.querySelectorAll("[data-pluto-variable]").forEach((el) => {
document.body.querySelectorAll("[data-pluto-variable], [data-cell-variable]").forEach((el) => {
el.setAttribute("data-ctrl-down", value ? "true" : "false")
})
}
Expand Down

0 comments on commit 469b82b

Please sign in to comment.