Skip to content

Commit

Permalink
lists: allow - [-] to be detected as checklist when pressing Enter
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed Jun 6, 2023
1 parent a23cc53 commit b2926ab
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions qmarkdowntextedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1458,8 +1458,8 @@ bool QMarkdownTextEdit::handleReturnEntered() {

// if return is pressed and there is just an unordered list symbol then we
// want to remove the list symbol Valid listCharacters: '+ ', '-' , '* ', '+
// [ ] ', '+ [x] ', '- [ ] ', '- [x] ', '* [ ] ', '* [x] '.
QRegularExpression regex(R"(^(\s*)([+|\-|\*] \[(x| |)\]|[+\-\*])(\s+)$)");
// [ ] ', '+ [x] ', '- [ ] ', '- [-] ', '- [x] ', '* [ ] ', '* [x] '.
QRegularExpression regex(R"(^(\s*)([+|\-|\*] \[(x|-| |)\]|[+\-\*])(\s+)$)");
QRegularExpressionMatchIterator iterator =
regex.globalMatch(currentLineText);
if (iterator.hasNext()) {
Expand Down Expand Up @@ -1497,9 +1497,9 @@ bool QMarkdownTextEdit::handleReturnEntered() {
// if the current line starts with a list character (possibly after
// whitespaces) add the whitespaces at the next line too
// Valid listCharacters: '+ ', '-' , '* ', '+ [ ] ', '+ [x] ', '- [ ] ',
// '- [x] ', '* [ ] ', '* [x] '.
// '- [x] ', '- [-] ', '* [ ] ', '* [x] '.
regex =
QRegularExpression(R"(^(\s*)([+|\-|\*] \[(x| |)\]|[+\-\*])(\s+))");
QRegularExpression(R"(^(\s*)([+|\-|\*] \[(x|-| |)\]|[+\-\*])(\s+))");
iterator = regex.globalMatch(currentLineText);
if (iterator.hasNext()) {
const QRegularExpressionMatch match = iterator.next();
Expand Down Expand Up @@ -1581,8 +1581,8 @@ bool QMarkdownTextEdit::handleTabEntered(bool reverse,

// check if we want to indent or un-indent an ordered list
// Valid listCharacters: '+ ', '-' , '* ', '+ [ ] ', '+ [x] ', '- [ ] ',
// '- [x] ', '* [ ] ', '* [x] '.
QRegularExpression re(R"(^(\s*)([+|\-|\*] \[(x| )\]|[+\-\*])(\s+)$)");
// '- [x] ', '- [-] ', '* [ ] ', '* [x] '.
QRegularExpression re(R"(^(\s*)([+|\-|\*] \[(x|-| )\]|[+\-\*])(\s+)$)");
QRegularExpressionMatchIterator i = re.globalMatch(currentLineText);

if (i.hasNext()) {
Expand Down

0 comments on commit b2926ab

Please sign in to comment.