From a10deb7edba50a355f43a7c7d70b9a517ffad20e Mon Sep 17 00:00:00 2001 From: Jason N Date: Tue, 22 Oct 2024 20:09:17 +1100 Subject: [PATCH] Insert indent to next tab stop --- src/lang/index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lang/index.js b/src/lang/index.js index 520f9ee..a6c744e 100644 --- a/src/lang/index.js +++ b/src/lang/index.js @@ -176,11 +176,16 @@ export function getExtensions(suffix, codeCheck, darkMode, readOnly = false) { if (state.selection.ranges.some((r) => !r.empty)) { return indentMore({ state, dispatch }); } + const pos = state.selection.main.from; + const col = pos - state.doc.lineAt(pos).from; dispatch( - state.update(state.replaceSelection(' '), { - scrollIntoView: true, - userEvent: 'input', - }), + state.update( + state.replaceSelection(col % 2 === 0 ? ' ' : ' '), + { + scrollIntoView: true, + userEvent: 'input', + }, + ), ); return true; },