Skip to content

Commit

Permalink
Insert indent to next tab stop
Browse files Browse the repository at this point in the history
  • Loading branch information
cyderize committed Oct 22, 2024
1 parent b002154 commit d277fc3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/lang/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down

0 comments on commit d277fc3

Please sign in to comment.