From 87299a5f8055bddb3fd95527775db83ba9a7dd36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Fri, 4 Jun 2021 16:01:09 +0200 Subject: [PATCH] fix: minor issue with list moves --- autoload/wiki/list/parser.vim | 8 ++++++-- test/test-list/test-move.vim | 4 ++-- test/wiki-basic/move_in.wiki | 7 +++++++ test/wiki-basic/move_out.wiki | 7 +++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/autoload/wiki/list/parser.vim b/autoload/wiki/list/parser.vim index d7c6e2a8..9ff07e87 100644 --- a/autoload/wiki/list/parser.vim +++ b/autoload/wiki/list/parser.vim @@ -89,7 +89,7 @@ function! s:get_list_items(opts) abort " {{{1 endfunction " }}}1 -function! s:get_tree_from_items(items) abort " +function! s:get_tree_from_items(items) abort " {{{1 if empty(a:items) | return {} | endif " Create root node @@ -134,7 +134,11 @@ function! s:get_tree_from_items(items) abort " " Update parent call add(l:parent.children, l:current) - let l:parent.lnum_last = l:current.lnum_end + let l:p = l:parent + while !empty(l:p) + let l:p.lnum_last = l:current.lnum_end + let l:p = l:p.parent + endwhile " Update total counter let l:counter += 1 diff --git a/test/test-list/test-move.vim b/test/test-list/test-move.vim index 0e83a648..3437b84a 100644 --- a/test/test-list/test-move.vim +++ b/test/test-list/test-move.vim @@ -1,7 +1,5 @@ source ../init.vim -let g:wiki_list_todos = ['TODO', 'INPROGRESS', 'DONE'] - silent edit ../wiki-basic/move_in.wiki call wiki#list#move(0, 5) @@ -12,6 +10,8 @@ call wiki#list#move(1, 3) call wiki#list#move(1, 6) call wiki#list#move(1, 20) +call wiki#list#move(0, 24) + let s:result = getline(1, '$') let s:reference = readfile('../wiki-basic/move_out.wiki') diff --git a/test/wiki-basic/move_in.wiki b/test/wiki-basic/move_in.wiki index 024d3d56..1c8f8f0e 100644 --- a/test/wiki-basic/move_in.wiki +++ b/test/wiki-basic/move_in.wiki @@ -18,3 +18,10 @@ * Depth two 1 single line * Depth two 2 three lines + +* A + * Aa + * Ab + * Ab1 + * Ab1i + diff --git a/test/wiki-basic/move_out.wiki b/test/wiki-basic/move_out.wiki index 5a61dd85..0b945f89 100644 --- a/test/wiki-basic/move_out.wiki +++ b/test/wiki-basic/move_out.wiki @@ -18,3 +18,10 @@ lines * Depth two 3 2 lines + +* A + * Ab + * Ab1 + * Ab1i + * Aa +