mirror of
https://github.com/freitass/todo.txt-vim.git
synced 2025-11-12 03:43:46 -05:00
When sorting on date, tasks with no date go to the end.
This commit is contained in:
@@ -79,7 +79,9 @@ function! todo#txt#sort_by_project() range
|
|||||||
execute a:firstline . "," . a:lastline . "sort /\\(^\\| \\)\\zs+[^[:blank:]]\\+/ r"
|
execute a:firstline . "," . a:lastline . "sort /\\(^\\| \\)\\zs+[^[:blank:]]\\+/ r"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! todo#txt#sort_by_date() range
|
function! todo#txt#sort_by_date() range
|
||||||
|
let l:date_regex = "\\d\\{2,4\\}-\\d\\{2\\}-\\d\\{2\\}"
|
||||||
|
execute a:firstline . "," . a:lastline . "sort /" . l:date_regex . "/ r"
|
||||||
execute a:firstline . "," . a:lastline . "g!/" . l:date_regex . "/m" . a:lastline
|
execute a:firstline . "," . a:lastline . "g!/" . l:date_regex . "/m" . a:lastline
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -3,3 +3,10 @@
|
|||||||
(B) 2012-04-16 2015-04-16
|
(B) 2012-04-16 2015-04-16
|
||||||
(A) 2013-03-16 2013-03-10
|
(A) 2013-03-16 2013-03-10
|
||||||
# end_lorem_ipsum
|
# end_lorem_ipsum
|
||||||
|
# task_with_no_date
|
||||||
|
2013-03-15 task with date
|
||||||
|
task with no date
|
||||||
|
2013-03-15 task with date
|
||||||
|
2013-03-15 task with date
|
||||||
|
task with no date
|
||||||
|
# end_task_with_no_date
|
||||||
|
|||||||
@@ -10,9 +10,22 @@ let s:SORTED_TASKS = [
|
|||||||
\ '(A) 2013-03-16 2013-03-10',
|
\ '(A) 2013-03-16 2013-03-10',
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
function! s:tc.test_sort_by_context()
|
let s:SORTED_TASKS_WITH_NO_DATE = [
|
||||||
|
\ '2013-03-15 task with date',
|
||||||
|
\ '2013-03-15 task with date',
|
||||||
|
\ '2013-03-15 task with date',
|
||||||
|
\ 'task with no date',
|
||||||
|
\ 'task with no date',
|
||||||
|
\ ]
|
||||||
|
|
||||||
|
function! s:tc.test_sort_by_date()
|
||||||
call self.data.visual_execute('call todo#txt#sort_by_date()', 'lorem_ipsum')
|
call self.data.visual_execute('call todo#txt#sort_by_date()', 'lorem_ipsum')
|
||||||
call self.assert_equal(s:SORTED_TASKS, self.data.get('lorem_ipsum'))
|
call self.assert_equal(s:SORTED_TASKS, self.data.get('lorem_ipsum'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:tc.test_sort_by_date_with_tasks_without_date()
|
||||||
|
call self.data.visual_execute('call todo#txt#sort_by_date()', 'task_with_no_date')
|
||||||
|
call self.assert_equal(s:SORTED_TASKS_WITH_NO_DATE, self.data.get('task_with_no_date'))
|
||||||
|
endfunction
|
||||||
|
|
||||||
unlet s:tc
|
unlet s:tc
|
||||||
|
|||||||
Reference in New Issue
Block a user