Fix weird behavior when pressing CR and Spaces follow
That's because Vim silently deletes the trailing whitespaces when pressing enter
This commit is contained in:
@ -1221,14 +1221,8 @@ function! s:cr_on_empty_line(lnum, behavior) "{{{
|
|||||||
elseif a:behavior == 1 || a:behavior == 4
|
elseif a:behavior == 1 || a:behavior == 4
|
||||||
normal! gi
|
normal! gi
|
||||||
x
|
x
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! s:cr_on_list_item(lnum, behavior, cur_col) "{{{
|
|
||||||
if a:behavior == 2 || a:behavior == 4 || (a:cur_col == 0 && getline(a:lnum) =~ '\s$')
|
|
||||||
" || (cur_item.lnum < s:get_last_line_of_item(cur_item))
|
|
||||||
normal! gi
|
|
||||||
|
|
||||||
|
|
||||||
function! s:cr_on_list_item(lnum, insert_new_marker) "{{{
|
function! s:cr_on_list_item(lnum, insert_new_marker) "{{{
|
||||||
if a:insert_new_marker
|
if a:insert_new_marker
|
||||||
@ -1236,6 +1230,12 @@ function! s:cr_on_list_item(lnum, behavior, cur_col) "{{{
|
|||||||
normal! gi
|
normal! gi
|
||||||
|
|
||||||
call s:clone_marker_from_to(a:lnum, a:lnum+1)
|
call s:clone_marker_from_to(a:lnum, a:lnum+1)
|
||||||
|
"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
|
||||||
|
else
|
||||||
|
" || (cur_item.lnum < s:get_last_line_of_item(cur_item))
|
||||||
"indent this line so that it becomes the continuation of the line above
|
"indent this line so that it becomes the continuation of the line above
|
||||||
normal! gi
|
normal! gi
|
||||||
|
|
||||||
@ -1254,14 +1254,22 @@ function! vimwiki#lst#kbd_cr(normal, just_mrkr) "{{{
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has_bp == 1
|
if has_bp == 1
|
||||||
|
call s:cr_on_empty_list_item(lnum, a:just_mrkr)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
let insert_new_marker = (a:normal == 1 || a:normal == 3)
|
||||||
|
if getline('.')[col("'^")-1:] =~ '^\s\+$'
|
||||||
|
let cur_col = 0
|
||||||
|
else
|
||||||
let cur_col = col("$") - col("'^")
|
let cur_col = col("$") - col("'^")
|
||||||
if insert_new_marker && cur_col == 0 && getline(lnum) =~ '\s$'
|
if insert_new_marker && cur_col == 0 && getline(lnum) =~ '\s$'
|
||||||
let insert_new_marker = 0
|
let insert_new_marker = 0
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has_bp == 0
|
if has_bp == 0
|
||||||
call s:cr_on_empty_line(lnum, a:normal)
|
call s:cr_on_empty_line(lnum, a:normal)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user