From fe9192ccaf758885b874ba44244e41a3dc0a09c5 Mon Sep 17 00:00:00 2001 From: Scharel Clemens Date: Wed, 5 Dec 2018 16:55:42 +0100 Subject: [PATCH] Auto-indent for new lines. --- qml/pages/EditPage.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qml/pages/EditPage.qml b/qml/pages/EditPage.qml index 3154e21..530d70b 100644 --- a/qml/pages/EditPage.qml +++ b/qml/pages/EditPage.qml @@ -53,7 +53,7 @@ Dialog { text: note.content font.family: appSettings.useMonoFont ? "DejaVu Sans Mono" : Theme.fontFamily // "Courier" property int preTextLength: 0 - property var listPrefixes: [/^- /gm, /^\* /gm, /^\+ /gm, /^- \[ \] /gm, /^- \[[xX]\] /gm, /^\d+. /gm] + property var listPrefixes: [/^( *)- /gm, /^( *)\* /gm, /^( *)\+ /gm, /^( *)- \[ \] /gm, /^( *)- \[[xX]\] /gm, /^( *)> /gm, /^( *)\d+. /gm] onTextChanged: { if (page.status === PageStatus.Active && text.length > preTextLength && @@ -63,9 +63,9 @@ Dialog { listPrefixes.forEach(function(currentValue, index) { var prefix = preLine.match(currentValue) if (prefix !== null) { - if (index === 5) { + if (index === listPrefixes.length-1) { var newListNumber = parseInt(prefix[0].split(". ")[0]) + 1 - clipboard = newListNumber.toString() + ". " + clipboard = prefix[0].replace(/\d/gm, newListNumber.toString()) } else { clipboard = prefix[0]