From 5e066c6989e6f1bfd4952da24673fa1393926f36 Mon Sep 17 00:00:00 2001 From: Paul Berg Date: Wed, 16 Oct 2024 16:30:52 +0200 Subject: [PATCH] tab multicursor --- frontend/components/CellInput.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/frontend/components/CellInput.js b/frontend/components/CellInput.js index 96d46dc64..c109ea488 100644 --- a/frontend/components/CellInput.js +++ b/frontend/components/CellInput.js @@ -365,15 +365,16 @@ export const CellInput = ({ return true } - // TODO Multicursor? - let selection = cm.state.selection.main - if (!selection.empty) { + const anySelect = cm.state.selection.ranges.some(r => !r.empty) + if (anySelect) { return indentMore(cm) } else { - cm.dispatch({ - changes: { from: selection.from, to: selection.to, insert: "\t" }, - selection: EditorSelection.cursor(selection.from + 1), - }) + cm.dispatch( + cm.state.changeByRange(selection => ({ + range: EditorSelection.cursor(selection.from + 1), + changes: { from: selection.from, to: selection.to, insert: "\t" }, + })) + ) return true } }