Skip to content

Commit

Permalink
Insert a pagebreak with ctrl/cmd + enter outside of list contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
CFiggers committed May 5, 2024
1 parent b261698 commit 11ec632
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/listEditing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ function onEnterKey(modifiers?: IModifier) {
editor.selection = new Selection(newCursorPos, newCursorPos);
}
}).then(() => { editor.revealRange(editor.selection) });

// Ordered list item before cursor
} else if ((matches = /^(\s*)([0-9]+)([.)])( +)((\[[ x]\] +)?)/.exec(textBeforeCursor)) !== null) {
// Ordered list
let config = workspace.getConfiguration('typst-companion.extension.orderedList').get<string>('marker');
Expand Down Expand Up @@ -166,7 +168,17 @@ function onEnterKey(modifiers?: IModifier) {
}
}).then(() => fixMarker(editor)).then(() => { editor.revealRange(editor.selection); });
} else {
return asNormal(editor, 'enter', modifiers);
if (modifiers == 'ctrl') {
return editor.edit(
editBuilder => {
editBuilder.insert(line.range.end, '#pagebreak()\n');
}
).then(() => {
editor.revealRange(editor.selection);
});
} else {
return asNormal(editor, 'enter', modifiers);
}
}
}

Expand Down

1 comment on commit 11ec632

@CFiggers
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to #6

Please sign in to comment.