From b2926abe78a98d79290106b17016e99a251f4a8c Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle Date: Tue, 6 Jun 2023 16:26:05 +0200 Subject: [PATCH] lists: allow `- [-] ` to be detected as checklist when pressing Enter --- qmarkdowntextedit.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qmarkdowntextedit.cpp b/qmarkdowntextedit.cpp index 054df37..729028d 100644 --- a/qmarkdowntextedit.cpp +++ b/qmarkdowntextedit.cpp @@ -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()) { @@ -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(); @@ -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()) {