Fix task todo might not toggle
which caused by not matching syntax with double dashes correctly
This commit is contained in:
		
							parent
							
								
									584f1c5249
								
							
						
					
					
						commit
						a9c88ce248
					
				@ -713,11 +713,11 @@ $.fn.sortByDepth = function () {
 | 
				
			|||||||
function toggleTodoEvent (e) {
 | 
					function toggleTodoEvent (e) {
 | 
				
			||||||
  const startline = $(this).closest('li').attr('data-startline') - 1
 | 
					  const startline = $(this).closest('li').attr('data-startline') - 1
 | 
				
			||||||
  const line = window.editor.getLine(startline)
 | 
					  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) {
 | 
					  if (matches && matches.length >= 2) {
 | 
				
			||||||
    let checked = null
 | 
					    let checked = null
 | 
				
			||||||
    if (matches[1] === 'x') { checked = true } else if (matches[1] === ' ') { checked = false }
 | 
					    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', {
 | 
					    window.editor.replaceRange(checked ? ' ' : 'x', {
 | 
				
			||||||
      line: startline,
 | 
					      line: startline,
 | 
				
			||||||
      ch: replacements[1].length
 | 
					      ch: replacements[1].length
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user