Issue 4: List folding doesn't work

Using new list functions to determine list fold level.
As a regression there is no folds for multilined list item's text.

1. item 1
2. item 2
   multilined
	 that is not
	 folded now
3. item 3

Previous method was able to fold item 2. I am not sure if we should fix
it or not.
This commit is contained in:
Maxim Kim
2013-07-24 11:09:41 +04:00
parent b26591437b
commit e30aa56722
2 changed files with 28 additions and 59 deletions

View File

@ -109,6 +109,7 @@ function! s:get_item(lnum) "{{{
return item
endif
let item.cb = matches[3]
if matches[1] != ''
@ -570,7 +571,6 @@ function! s:update_state(item) "{{{
endif
endfunction "}}}
"Creates checkbox in a list item.
"Returns: 1 if successful
function! s:create_cb(item) "{{{
@ -896,7 +896,6 @@ function! vimwiki#lst#remove_cb_in_list() "{{{
call s:update_state(s:get_parent(first_item))
endfunction "}}}
function! vimwiki#lst#change_marker_in_list(new_mrkr) "{{{
let cur_item = s:get_corresponding_item(line('.'))
let first_item = s:get_first_item_in_list(cur_item, 0)
@ -1103,7 +1102,6 @@ function! s:indent_multiline(prev_item, lnum) "{{{
endif
endfunction "}}}
function! vimwiki#lst#kbd_o() "{{{
let fold_end = foldclosedend('.')
let lnum = (fold_end == -1) ? line('.') : fold_end
@ -1160,7 +1158,7 @@ function! s:create_marker(lnum) "{{{
endif
endfunction "}}}
function! s:cr_on_empty_list_item(lnum, behavior)
function! s:cr_on_empty_list_item(lnum, behavior) "{{{
if a:behavior == 1
"just make a new list item
normal! gi
@ -1212,18 +1210,18 @@ function! s:cr_on_empty_list_item(lnum, behavior)
startinsert
endif
return
endif
endif
endfunction "}}}
function! s:cr_on_empty_line(lnum, behavior) "{{{
if a:behavior == 2 || a:behavior == 3
normal! gi

call s:create_marker(a:lnum+1)
elseif a:behavior == 1 || a:behavior == 4
normal! gi
normal! gi
x
endif
endif
endfunction "}}}
function! s:cr_on_list_item(lnum, behavior, cur_col) "{{{
@ -1239,7 +1237,7 @@ function! s:cr_on_list_item(lnum, behavior, cur_col)
normal! gi

call s:clone_marker_from_to(a:lnum, a:lnum+1)
"tiny sweet extra feature: indent next line if current line ends with :
"tiny sweet extra feature: indent next line if current line ends with :
if getline(a:lnum) =~ ':$'
call s:change_level(a:lnum+1, a:lnum+1, 'increase', 0)
endif
@ -1318,7 +1316,7 @@ function! vimwiki#lst#get_list_margin() "{{{
function! vimwiki#lst#get_list_margin() "{{{
if VimwikiGet('list_margin') < 0
return &sw
else
else
return VimwikiGet('list_margin')
endif
endfunction "}}}
@ -1352,4 +1350,20 @@ function! vimwiki#lst#setup_marker_infos()
endfor
let g:vimwiki_rxListNumber .= s:char_to_rx[g:vimwiki_number_types[-1][0]] .
\ vimwiki#u#escape(g:vimwiki_number_types[-1][1]) . '\)'
else
else
"regex that matches nothing
let g:vimwiki_rxListNumber = '$^'
endif
endfunction "}}}
fun! vimwiki#lst#fold_level(lnum) "{{{
let cur_item = s:get_item(a:lnum)
if cur_item.type != 0
let parent_item = s:get_parent(cur_item)
let child_item = s:get_first_child(cur_item)
let next_item = s:get_next_child_item(parent_item, cur_item)
if child_item.type != 0
return 'a1'
elseif next_item.type == 0
return 's1'