Properly handle lists with hard wraps. Fixes #443.
This change modifies the behavior of VimwikiReturn to not insert a new list marker if not within a list. Mostly useful when mapping <CR> to VimwikiReturn 3 5 or similar. The behavior of 'o' was also modified to properly insert a marker in a list with hard line wraps.
This commit is contained in:
parent
b5d808b440
commit
5ce7c14a3d
@ -1465,13 +1465,14 @@ function! vimwiki#lst#kbd_o()
|
|||||||
let fold_end = foldclosedend('.')
|
let fold_end = foldclosedend('.')
|
||||||
let lnum = (fold_end == -1) ? line('.') : fold_end
|
let lnum = (fold_end == -1) ? line('.') : fold_end
|
||||||
let cur_item = s:get_item(lnum)
|
let cur_item = s:get_item(lnum)
|
||||||
|
let parent = s:get_corresponding_item(lnum)
|
||||||
"inserting and deleting the x is necessary
|
"inserting and deleting the x is necessary
|
||||||
"because otherwise the indent is lost
|
"because otherwise the indent is lost
|
||||||
exe 'normal!' "ox\<C-H>"
|
exe 'normal!' "ox\<C-H>"
|
||||||
if cur_item.lnum < s:get_last_line_of_item(cur_item)
|
if parent.type != 0
|
||||||
call s:indent_multiline(cur_item, cur_item.lnum+1)
|
call s:clone_marker_from_to(parent.lnum, cur_item.lnum+1)
|
||||||
else
|
else
|
||||||
call s:clone_marker_from_to(cur_item.lnum, cur_item.lnum+1)
|
call s:indent_multiline(cur_item, cur_item.lnum+1)
|
||||||
endif
|
endif
|
||||||
startinsert!
|
startinsert!
|
||||||
endfunction
|
endfunction
|
||||||
@ -1547,11 +1548,19 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
function! s:cr_on_empty_line(lnum, behavior)
|
function! s:cr_on_empty_line(lnum, behavior)
|
||||||
|
let lst = s:get_corresponding_item(a:lnum)
|
||||||
|
|
||||||
"inserting and deleting the x is necessary
|
"inserting and deleting the x is necessary
|
||||||
"because otherwise the indent is lost
|
"because otherwise the indent is lost
|
||||||
exe 'normal!' "gi\<CR>x\<C-H>\<ESC>"
|
exe 'normal!' "gi\<CR>x\<C-H>\<ESC>"
|
||||||
|
|
||||||
if a:behavior == 2 || a:behavior == 3
|
if a:behavior == 2 || a:behavior == 3
|
||||||
call s:create_marker(a:lnum+1)
|
if lst.type == 0
|
||||||
|
" don't insert new bullet if not part of a list
|
||||||
|
return
|
||||||
|
else
|
||||||
|
call s:create_marker(a:lnum+1)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user