Bug fixes for case sensitivity and cursor positioning

This commit is contained in:
fretep
2017-09-14 00:27:03 +10:00
parent 0ed7d4848e
commit ff533b85f5
3 changed files with 36 additions and 34 deletions

View File

@@ -193,7 +193,7 @@ function! todo#SortDue()
execute "silent " . l:firstLineWithDue . ",$move 0"
endif
" Change the due:yyyymmdd back to due:yyyy-mm-dd.
silent! %substitute/\v<(due:\d{4})(\d{2})(\d{2})>/\1-\2-\3/ei
silent! %substitute/\v<(due:\d{4})(\d{2})(\d{2})>/\1-\2-\3/ei
silent global/\C^x /move$
" Let's check a global for a user preference on the cursor position.
if exists("g:TodoTxtSortDueDateCursorPos")
@@ -203,8 +203,8 @@ function! todo#SortDue()
silent normal G
" Sorry for the crazy RegExp. The next command should put cursor at at the top of the completed tasks,
" or the bottom of the buffer. This is done by searching backwards for any line not starting with
" "x " (x, space) which is important to distinguish from "xample task" for instance, which the more
" simple "^[^x]" would match. More info: ":help /\@!".
" "x " (x, space) which is important to distinguish from "xample task" for instance, which the more
" simple "^[^x]" would match. More info: ":help /\@!". Be sure to enforce case sensitivity on "x".
:silent! ?\v\C^(x )@!?+1
let l:overduePat = todo#GetDateRegexForPastDates()
let l:lastwrapscan = &wrapscan
@@ -212,6 +212,9 @@ function! todo#SortDue()
try
if g:TodoTxtSortDueDateCursorPos ==? "lastdue"
" This searches backwards for the last due task
:?\v\c<due:\d{4}\-\d{2}\-\d{2}>
" Try a forward search in case the last line of the buffer was a due:date task, don't match done
" Be sure to enforce case sensitivity on "x" while allowing mixed case on "due:"
:silent! /\v\C^(x )@!&.*<[dD][uU][eE]:\d{4}\-\d{2}\-\d{2}>
elseif g:TodoTxtSortDueDateCursorPos ==? "notoverdue"
" This searches backwards for the last overdue task, and positions the cursor on the following line
@@ -223,7 +226,6 @@ function! todo#SortDue()
normal gg
finally
let &wrapscan = l:lastwrapscan
endtry
endtry
elseif g:TodoTxtSortDueDateCursorPos ==? "bottom"
silent normal G

View File

@@ -31,11 +31,11 @@ endfunction
function! todo#txt#replace_date()
let current_line = getline('.')
if (current_line =~ '^\(([a-zA-Z]) \)\?\d\{2,4\}-\d\{2\}-\d\{2\} ') &&
if (current_line =~ '^\(([A-Z]) \)\?\d\{2,4\}-\d\{2\}-\d\{2\} ') &&
\ exists('g:todo_existing_date') && g:todo_existing_date == 'n'
return
endif
execute 's/^\(([a-zA-Z]) \)\?\(\d\{2,4\}-\d\{2\}-\d\{2\} \)\?/\1' . s:get_current_date() . ' /'
execute 's/^\(([A-Z]) \)\?\(\d\{2,4\}-\d\{2\}-\d\{2\} \)\?/\1' . s:get_current_date() . ' /'
endfunction
function! todo#txt#mark_as_done()
@@ -116,7 +116,7 @@ function! todo#txt#prioritize_add(priority)
endfunction
function! todo#txt#prioritize_add_action(priority)
execute 's/^\(([a-zA-Z]) \)\?/(' . a:priority . ') /'
execute 's/^\(([A-Z]) \)\?/(' . a:priority . ') /'
endfunction
" Modeline {{{1