mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-06 20:54:31 +08:00
Better handling of insert_eol_marker. Should fix #195.
This commit is contained in:
@@ -474,8 +474,10 @@ function! delimitMate#ExpandReturn() "{{{
|
|||||||
\ || expand_inside_quotes)
|
\ || expand_inside_quotes)
|
||||||
let val = "\<Esc>a"
|
let val = "\<Esc>a"
|
||||||
if is_empty_matchpair && s:get('insert_eol_marker') == 2
|
if is_empty_matchpair && s:get('insert_eol_marker') == 2
|
||||||
let repeat = search('\s\%#\s', 'bcnW', '.') ? 2 : 1
|
\ && !search(escape(s:get('eol_marker'), '[]\.*^$').'$', 'cnW', '.')
|
||||||
let val .= repeat("\<Right>", repeat) . s:get('eol_marker') . repeat("\<Left>", repeat + 1)
|
let tail = getline('.')[col('.') - 1 : ]
|
||||||
|
let times = len(split(tail, '\zs'))
|
||||||
|
let val .= repeat("\<Right>", times) . s:get('eol_marker') . repeat("\<Left>", times + 1)
|
||||||
endif
|
endif
|
||||||
let val .= "\<CR>"
|
let val .= "\<CR>"
|
||||||
if &smartindent && !&cindent && !&indentexpr
|
if &smartindent && !&cindent && !&indentexpr
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
let g:delimitMate_expand_cr = 1
|
let g:delimitMate_expand_cr = 1
|
||||||
let g:delimitMate_eol_marker = ';'
|
let g:delimitMate_eol_marker = ';'
|
||||||
call vimtest#StartTap()
|
call vimtest#StartTap()
|
||||||
call vimtap#Plan(6)
|
call vimtap#Plan(8)
|
||||||
" NOTE: Do not forget to update the plan ^
|
" NOTE: Do not forget to update the plan ^
|
||||||
let g:delimitMate_insert_eol_marker = 0
|
let g:delimitMate_insert_eol_marker = 0
|
||||||
DelimitMateReload
|
DelimitMateReload
|
||||||
@@ -9,22 +9,36 @@ normal i(
|
|||||||
call vimtap#Is(getline(1), '()', 'value = 1, case 1')
|
call vimtap#Is(getline(1), '()', 'value = 1, case 1')
|
||||||
%d _
|
%d _
|
||||||
exec "normal i(\<CR>x"
|
exec "normal i(\<CR>x"
|
||||||
call vimtap#Like(join(getline(1,line('$')), "\<NL>"), '^(\n\s*x\n)$', 'Value = 2, case 2')
|
call vimtap#Like(join(getline(1,line('$')), "\<NL>"),
|
||||||
|
\ '^(\n\s*x\n)$', ' "normal i(\<CR>x", Value = 2, case 2')
|
||||||
let g:delimitMate_insert_eol_marker = 1
|
let g:delimitMate_insert_eol_marker = 1
|
||||||
DelimitMateReload
|
DelimitMateReload
|
||||||
%d _
|
%d _
|
||||||
normal i(
|
normal i(
|
||||||
call vimtap#Is(getline(1), '();', 'value = 1, case 1')
|
call vimtap#Is(getline(1), '();', '"normal i(", value = 1, case 1')
|
||||||
%d _
|
%d _
|
||||||
exec "normal i(\<CR>x"
|
exec "normal i(\<CR>x"
|
||||||
call vimtap#Like(join(getline(1,line('$')), "\<NL>"), '^(\n\s*x\n);$', 'Value = 2, case 2')
|
call vimtap#Like(join(getline(1,line('$')), "\<NL>"),
|
||||||
|
\ '^(\n\s*x\n);$', '"normal i(\<CR>x", Value = 2, case 2')
|
||||||
%d _
|
%d _
|
||||||
let g:delimitMate_insert_eol_marker = 2
|
let g:delimitMate_insert_eol_marker = 2
|
||||||
DelimitMateReload
|
DelimitMateReload
|
||||||
normal i(
|
normal i(
|
||||||
call vimtap#Is(getline(1), '()', 'Value = 2, case 1')
|
call vimtap#Is(getline(1), '()', '"normal i(", Value = 2, case 1')
|
||||||
%d _
|
%d _
|
||||||
exec "normal i(\<CR>x"
|
exec "normal i(\<CR>x"
|
||||||
call vimtap#Like(join(getline(1,line('$')), "\<NL>"), '^(\n\s*x\n);$', 'Value = 2, case 2')
|
call vimtap#Like(join(getline(1,line('$')), "\<NL>"),
|
||||||
call vimtest#Quit()
|
\ '^(\n\s*x\n);$', '"normal i(\<CR>x", Value = 2, case 2')
|
||||||
|
|
||||||
|
%d _
|
||||||
|
exec "normal i{(\<CR>x"
|
||||||
|
call vimtap#Like(join(getline(1,line('$')), "\<NL>"),
|
||||||
|
\ '^{(\n\s*x\n)};$', ' "normal i{(\<CR>x", Value = 2, case 3')
|
||||||
|
|
||||||
|
%d _
|
||||||
|
exec "normal i;\<Esc>I{(\<CR>x"
|
||||||
|
call vimtap#Like(join(getline(1,line('$')), "\<NL>"),
|
||||||
|
\ '^{(\n\s*x\n)};$', ' "normal i{(\<CR>x", Value = 2, case 4')
|
||||||
|
|
||||||
|
" End: quit vim.
|
||||||
|
call vimtest#Quit()
|
||||||
|
|||||||
Reference in New Issue
Block a user