diff --git a/autoload/delimitMate.vim b/autoload/delimitMate.vim index 5047bd8..ec08525 100644 --- a/autoload/delimitMate.vim +++ b/autoload/delimitMate.vim @@ -474,8 +474,10 @@ function! delimitMate#ExpandReturn() "{{{ \ || expand_inside_quotes) let val = "\a" if is_empty_matchpair && s:get('insert_eol_marker') == 2 - let repeat = search('\s\%#\s', 'bcnW', '.') ? 2 : 1 - let val .= repeat("\", repeat) . s:get('eol_marker') . repeat("\", repeat + 1) + \ && !search(escape(s:get('eol_marker'), '[]\.*^$').'$', 'cnW', '.') + let tail = getline('.')[col('.') - 1 : ] + let times = len(split(tail, '\zs')) + let val .= repeat("\", times) . s:get('eol_marker') . repeat("\", times + 1) endif let val .= "\" if &smartindent && !&cindent && !&indentexpr diff --git a/test/eol_marker.vim b/test/eol_marker.vim index 7853b51..d414355 100644 --- a/test/eol_marker.vim +++ b/test/eol_marker.vim @@ -1,7 +1,7 @@ let g:delimitMate_expand_cr = 1 let g:delimitMate_eol_marker = ';' call vimtest#StartTap() -call vimtap#Plan(6) +call vimtap#Plan(8) " NOTE: Do not forget to update the plan ^ let g:delimitMate_insert_eol_marker = 0 DelimitMateReload @@ -9,22 +9,36 @@ normal i( call vimtap#Is(getline(1), '()', 'value = 1, case 1') %d _ exec "normal i(\x" -call vimtap#Like(join(getline(1,line('$')), "\"), '^(\n\s*x\n)$', 'Value = 2, case 2') +call vimtap#Like(join(getline(1,line('$')), "\"), + \ '^(\n\s*x\n)$', ' "normal i(\x", Value = 2, case 2') let g:delimitMate_insert_eol_marker = 1 DelimitMateReload %d _ normal i( -call vimtap#Is(getline(1), '();', 'value = 1, case 1') +call vimtap#Is(getline(1), '();', '"normal i(", value = 1, case 1') %d _ exec "normal i(\x" -call vimtap#Like(join(getline(1,line('$')), "\"), '^(\n\s*x\n);$', 'Value = 2, case 2') +call vimtap#Like(join(getline(1,line('$')), "\"), + \ '^(\n\s*x\n);$', '"normal i(\x", Value = 2, case 2') %d _ let g:delimitMate_insert_eol_marker = 2 DelimitMateReload normal i( -call vimtap#Is(getline(1), '()', 'Value = 2, case 1') +call vimtap#Is(getline(1), '()', '"normal i(", Value = 2, case 1') %d _ exec "normal i(\x" -call vimtap#Like(join(getline(1,line('$')), "\"), '^(\n\s*x\n);$', 'Value = 2, case 2') -call vimtest#Quit() +call vimtap#Like(join(getline(1,line('$')), "\"), + \ '^(\n\s*x\n);$', '"normal i(\x", Value = 2, case 2') +%d _ +exec "normal i{(\x" +call vimtap#Like(join(getline(1,line('$')), "\"), + \ '^{(\n\s*x\n)};$', ' "normal i{(\x", Value = 2, case 3') + +%d _ +exec "normal i;\I{(\x" +call vimtap#Like(join(getline(1,line('$')), "\"), + \ '^{(\n\s*x\n)};$', ' "normal i{(\x", Value = 2, case 4') + +" End: quit vim. +call vimtest#Quit()