Skip to content

Commit

Permalink
fix: minor issue with list moves
Browse files Browse the repository at this point in the history
  • Loading branch information
lervag committed Jun 4, 2021
1 parent 0b9ff33 commit 87299a5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
8 changes: 6 additions & 2 deletions autoload/wiki/list/parser.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/test-list/test-move.vim
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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')

Expand Down
7 changes: 7 additions & 0 deletions test/wiki-basic/move_in.wiki
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@
* Depth two 1 single line
* Depth two 2
three lines
* A
* Aa
* Ab
* Ab1
* Ab1i
7 changes: 7 additions & 0 deletions test/wiki-basic/move_out.wiki
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@
lines
* Depth two 3
2 lines
* A
* Ab
* Ab1
* Ab1i
* Aa

0 comments on commit 87299a5

Please sign in to comment.