summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Beniamine <david.beniamine@tetras-libre.fr>2020-12-24 10:56:09 +0000
committerDavid Beniamine <david.beniamine@tetras-libre.fr>2020-12-24 10:56:09 +0000
commit31273332babf2d3360e9d363e92d384c354ef96f (patch)
tree4b6aff7a7aeba3b9b71152305f49f9fb53c3991c
parent268de84cda9278c5f24a38664df00750a195833b (diff)
parentca056558664a04d176c70b40d5796adf72a0b6e5 (diff)
downloadtodo.txt-vim-31273332babf2d3360e9d363e92d384c354ef96f.zip
Merge branch 'dev-fold' into 'master'
Enable user to prevent fold method change after sorting See merge request dbeniamine/todo.txt-vim!40
-rw-r--r--README.markdown11
-rw-r--r--autoload/todo.vim8
-rw-r--r--doc/todo.txt14
-rw-r--r--ftplugin/todo.vim5
4 files changed, 31 insertions, 7 deletions
diff --git a/README.markdown b/README.markdown
index 564ce39..da08ccd 100644
--- a/README.markdown
+++ b/README.markdown
@@ -335,7 +335,14 @@ disable this behavior by setting the following global variable:
## Fold
-Todo.txt files can be folded by projects or context (see `:help fold`), by
-default they are foldable by context, to use project fold :
+Todo.txt files can be folded by projects or context (see `:help fold`). By
+default they are foldable by context. To use project fold add the following to
+your vimrc:
let g:Todo_fold_char='+'
+
+Note that the fold method by default changes to match the sort order regardless
+of what Todo_fold_char is set to. If you prefer to keep the fold method
+constant even after changing the sort method set the variable below as follows:
+
+ let g:Todo_update_fold_on_sort=0
diff --git a/autoload/todo.vim b/autoload/todo.vim
index e53c941..d8fb172 100644
--- a/autoload/todo.vim
+++ b/autoload/todo.vim
@@ -167,7 +167,9 @@ endfunction
function! todo#Sort(type)
" vim :sort is usually stable
" we sort first on contexts, then on projects and then on priority
- let g:Todo_fold_char='x'
+ if g:Todo_update_fold_on_sort
+ let g:Todo_fold_char=a:type
+ endif
let oldcursor=todo#GetCurpos()
if(a:type != "")
exec ':sort /.\{-}\ze'.a:type.'/'
@@ -297,7 +299,9 @@ function! todo#HierarchicalSort(symbol, symbolsub, dolastsort)
"Empty buffer do nothing
return
endif
- let g:Todo_fold_char=a:symbol
+ if g:Todo_update_fold_on_sort
+ let g:Todo_fold_char=a:symbol
+ endif
"if the sort modes doesn't start by '!' it must start with a space
let l:sortmode=Todo_txt_InsertSpaceIfNeeded(g:Todo_txt_first_level_sort_mode)
let l:sortmodesub=Todo_txt_InsertSpaceIfNeeded(g:Todo_txt_second_level_sort_mode)
diff --git a/doc/todo.txt b/doc/todo.txt
index a6925da..7f5cc0d 100644
--- a/doc/todo.txt
+++ b/doc/todo.txt
@@ -369,8 +369,16 @@ disable this behavior by setting the following global variable:
===============================================================================
8. Fold *TodoTxt-fold* ~
-Todo.txt files can be folded by projects or context (see |fold|), by default
-they are foldable by context, to use project fold :
+Todo.txt files can be folded by projects or context (see |fold|). By default
+they are foldable by context. To use project fold add the following to
+your vimrc:
>
-
let g:Todo_fold_char='+'
+<
+
+Note that the fold method by default changes to match the sort order regardless
+of what Todo_fold_char is set to. If you prefer to keep the fold method
+constant even after changing the sort method set the variable below as follows:
+>
+ let g:Todo_update_fold_on_sort=0
+<
diff --git a/ftplugin/todo.vim b/ftplugin/todo.vim
index 4bc3cb9..12133ea 100644
--- a/ftplugin/todo.vim
+++ b/ftplugin/todo.vim
@@ -121,6 +121,11 @@ setlocal foldmethod=expr
setlocal foldexpr=TodoFoldLevel(v:lnum)
setlocal foldtext=TodoFoldText()
+" Update fold method after sort by default
+if ! exists("g:Todo_update_fold_on_sort")
+ let g:Todo_update_fold_on_sort=1
+endif
+
" Go to first completed task
let oldpos=getcurpos()
if(!exists("g:Todo_fold_char"))