diff --git a/autoload/vimwiki/lst.vim b/autoload/vimwiki/lst.vim index 389f368..26966bc 100644 --- a/autoload/vimwiki/lst.vim +++ b/autoload/vimwiki/lst.vim @@ -419,11 +419,13 @@ function! s:get_next_line(lnum, ...) while cur_ln <= line('$') && getline(cur_ln) !~# vimwiki#vars#get_syntaxlocal('rxPreEnd') let cur_ln += 1 endwhile - let next_line = cur_ln + let next_line = cur_ln + 1 else - let next_line = nextnonblank(a:lnum+1) + let next_line = a:lnum + 1 endif + let next_line = nextnonblank(next_line) + if a:0 > 0 && getline(next_line) =~# vimwiki#vars#get_syntaxlocal('rxHeader') let next_line = s:get_next_line(next_line, 1) endif @@ -440,19 +442,19 @@ endfunction "Returns: lnum-1 in most cases, but skips blank lines and preformatted text "0 in case of nonvalid line and a header, because a header ends every list function! s:get_prev_line(lnum) - let prev_line = prevnonblank(a:lnum-1) + let cur_ln = a:lnum - 1 - if getline(prev_line) =~# vimwiki#vars#get_syntaxlocal('rxPreEnd') - let cur_ln = a:lnum - 1 + if getline(cur_ln) =~# vimwiki#vars#get_syntaxlocal('rxPreEnd') while 1 if cur_ln == 0 || getline(cur_ln) =~# vimwiki#vars#get_syntaxlocal('rxPreStart') break endif let cur_ln -= 1 endwhile - let prev_line = cur_ln endif + let prev_line = prevnonblank(cur_ln) + if prev_line < 0 || prev_line > line('$') || \ getline(prev_line) =~# vimwiki#vars#get_syntaxlocal('rxHeader') return 0 diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 17ea075..cedf960 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -3479,6 +3479,8 @@ https://github.com/vimwiki-backup/vimwiki/issues. 2.5 (in progress)~ New:~ + * PR #735: Make list-toggling work properly even when code blocks are + embedded within the list in Markdown mode. * PR #711: Allow forcing VimwikiAll2HTML with ! * PR #702: Make remapping documentation more accessible to newer vim users * PR #673: Add :VimwikiGoto key mapping. diff --git a/test/list_update.vader b/test/list_update.vader new file mode 100644 index 0000000..9c5b10e --- /dev/null +++ b/test/list_update.vader @@ -0,0 +1,191 @@ +Include: vader_includes/vader_setup.vader + +Given vimwiki (Sample nested list, vimwiki syntax): + * [ ] Top Level + * [ ] Child 1 + * [ ] Child 2 + + * [ ] Post space + + {{{code + * [ ] print "hello, world" + }}} + + {{{morecode + print "hello again" + }}} + + * [ ] Post code + * [ ] Sub-child + + * [ ] Sub-sub-child + +Execute (Set syntax to default): + call SetSyntax('default') + +Do (Toggle top-level): + \ + +Expect (All tree toggled): + * [X] Top Level + * [X] Child 1 + * [X] Child 2 + + * [X] Post space + + {{{code + * [ ] print "hello, world" + }}} + + {{{morecode + print "hello again" + }}} + + * [X] Post code + * [X] Sub-child + + * [X] Sub-sub-child + +Do (Toggle child): + j + \ + +Expect (Child toggled, top updated): + * [.] Top Level + * [X] Child 1 + * [ ] Child 2 + + * [ ] Post space + + {{{code + * [ ] print "hello, world" + }}} + + {{{morecode + print "hello again" + }}} + + * [ ] Post code + * [ ] Sub-child + + * [ ] Sub-sub-child + +Do (Toggle sub-child): + G + \ + +Expect (Sub-child toggled, parents updated): + * [.] Top Level + * [ ] Child 1 + * [ ] Child 2 + + * [ ] Post space + + {{{code + * [ ] print "hello, world" + }}} + + {{{morecode + print "hello again" + }}} + + * [o] Post code + * [ ] Sub-child + + * [X] Sub-sub-child + +Given markdown (Sample nested list, markdown syntax): + * [ ] Top Level + * [ ] Child 1 + * [ ] Child 2 + + * [ ] Post space + + ```code + * [ ] print "hello, world" + ``` + + ```morecode + print "hello again" + ``` + + * [ ] Post code + * [ ] Sub-child + + * [ ] Sub-sub-child + +Execute (Set syntax to markdown): + call SetSyntax('markdown') + +Do (Toggle top-level): + \ + +Expect (All tree toggled): + * [X] Top Level + * [X] Child 1 + * [X] Child 2 + + * [X] Post space + + ```code + * [ ] print "hello, world" + ``` + + ```morecode + print "hello again" + ``` + + * [X] Post code + * [X] Sub-child + + * [X] Sub-sub-child + +Do (Toggle child): + j + \ + +Expect (Child toggled, top updated): + * [.] Top Level + * [X] Child 1 + * [ ] Child 2 + + * [ ] Post space + + ```code + * [ ] print "hello, world" + ``` + + ```morecode + print "hello again" + ``` + + * [ ] Post code + * [ ] Sub-child + + * [ ] Sub-sub-child + +Do (Toggle sub-child): + G + \ + +Expect (Sub-child toggled, parents updated): + * [.] Top Level + * [ ] Child 1 + * [ ] Child 2 + + * [ ] Post space + + ```code + * [ ] print "hello, world" + ``` + + ```morecode + print "hello again" + ``` + + * [o] Post code + * [ ] Sub-child + + * [X] Sub-sub-child + +Include: vader_includes/vader_teardown.vader