From a9c88ce2483bfbba2ddf55f9f9d34fbfcf3281d4 Mon Sep 17 00:00:00 2001 From: Max Wu Date: Wed, 24 Jan 2018 00:10:52 +0800 Subject: [PATCH] Fix task todo might not toggle which caused by not matching syntax with double dashes correctly --- public/js/extra.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/js/extra.js b/public/js/extra.js index ec7d39da8..dbb0f4581 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -713,11 +713,11 @@ $.fn.sortByDepth = function () { function toggleTodoEvent (e) { const startline = $(this).closest('li').attr('data-startline') - 1 const line = window.editor.getLine(startline) - const matches = line.match(/^[>\s]*[-+*]\s\[([x ])\]/) + const matches = line.match(/^[>\s-]*[-+*]\s\[([x ])\]/) if (matches && matches.length >= 2) { let checked = null if (matches[1] === 'x') { checked = true } else if (matches[1] === ' ') { checked = false } - const replacements = matches[0].match(/(^[>\s]*[-+*]\s\[)([x ])(\])/) + const replacements = matches[0].match(/(^[>\s-]*[-+*]\s\[)([x ])(\])/) window.editor.replaceRange(checked ? ' ' : 'x', { line: startline, ch: replacements[1].length