diff --git a/autoload/delimitMate.vim b/autoload/delimitMate.vim index 35db4e4..398e1fa 100644 --- a/autoload/delimitMate.vim +++ b/autoload/delimitMate.vim @@ -53,10 +53,15 @@ function! delimitMate#ex_cmd(global, action) endfunction function! delimitMate#InsertCharPre(str) - if s:option('disabled') + if s:info.skip_icp echom 11 return 0 endif + let s:info.skip_icp = 1 + if s:option('disabled') + echom 12 + return 0 + endif return map(split(a:str, '\zs'), 's:handle_vchar(v:val)') endfunction @@ -69,8 +74,7 @@ function! s:handle_vchar(str) return elseif a:str == ' ' echom 13 - let [keys, append2vchar] = s:keys4space(s:info, opts) - let v:char .= append2vchar + let keys = s:keys4space(s:info, opts) elseif a:str == "\" echom 14 return 0 @@ -80,8 +84,7 @@ function! s:handle_vchar(str) elseif !empty(filter(copy(opts.pairs), 'strcharpart(v:val, 0, 1) ==# a:str')) echom 16 let pair = get(filter(copy(opts.pairs), 'strcharpart(v:val, 0, 1) ==# a:str'), 0, '') - let [keys, append2vchar] = s:keys4left(a:str, pair, s:info, opts) - let v:char .= append2vchar + let keys = s:keys4left(a:str, pair, s:info, opts) "echom strtrans(keys) "echom string(pair) elseif !empty(filter(copy(opts.pairs), 'strcharpart(v:val, 1, 1) ==# a:str')) @@ -97,18 +100,17 @@ function! s:handle_vchar(str) endfunction function! s:keys4space(info, opts) - if !a:opts.expand_space && !empty(filter(copy(a:opts.pairs), 'v:val ==# a:info.cur.around')) - return ['', ''] + if !a:opts.expand_space || empty(filter(copy(a:opts.pairs), 'v:val ==# a:info.cur.around')) + return '' endif - if a:opts.expand_space - return ["\U\", ' '] + return " \U\" endfunction function! s:keys4left(char, pair, info, opts) if a:opts.autoclose - return [strcharpart(a:pair, 1, 1) . "\U\", ''] + return strcharpart(a:pair, 1, 1) . "\U\" endif - return ['', ''] + return '' endfunction function! s:keys4right(char, pair, info, opts) @@ -149,6 +151,7 @@ endfunction function! delimitMate#CursorMovedI(...) let s:info.prev = s:info.cur let s:info.cur = call('s:get_info', a:000) + let s:info.skip_icp = 0 echom 'INFO: ' . string(s:info) echom 'CMI: ' . s:info.prev.text endfunction @@ -156,6 +159,7 @@ endfunction function! delimitMate#InsertEnter(...) let s:info.cur = call('s:get_info', a:000) let s:info.prev = {} + let s:info.skip_icp = 0 echom 'IE: ' . s:info.cur.text endfunction diff --git a/test/autoclose_matchpairs.vim b/test/autoclose_matchpairs.vim index 3f43278..74fe0ce 100644 --- a/test/autoclose_matchpairs.vim +++ b/test/autoclose_matchpairs.vim @@ -20,7 +20,7 @@ call DMTest_pairs('()', ["a\"], "") call DMTest_pairs('()', ["a)", 'ax'], "()x") "call DMTest_pairs('', "((\gx", "(())x") call DMTest_pairs('', ["i(x\u"], "") -call DMTest_pairs('', ["i@(","ax"], "@(x)") +call DMTest_pairs('', ["i@", "a(","ax"], "@(x)") call DMTest_pairs('@#', ["a(","ax"], "@(x)#") call DMTest_pairs('\', ["a(","ax"], '\(x') call DMTest_pairs('', ["a(",'a\', 'a)', "ax"], '(\)x)') @@ -36,8 +36,9 @@ let g:delimitMate_expand_space = 1 let g:delimitMate_autoclose = 1 call DMTest_pairs('', ['i(', "a\", 'ax'], "( x )") " needs to be after so the cursor stays in the expected place for when -" the doau commands fire. -call DMTest_pairs('( )', ["2|a\\"], 'ix'], "(x)") +" the :doau commands fire. +call DMTest_pairs('( )', ["2|a\\", 'ix'], "(x)") +call DMTest_pairs('', ["iabc ", 'ax'], "abc x") let g:delimitMate_autoclose = 0 call DMTest_pairs('', ["i(", "a)", "a\", "a\\", "ix"], "(x)") let g:delimitMate_autoclose = 1 @@ -57,7 +58,8 @@ call DMTest_pairs('', ["i(", "aa", "i)"], "()a)") "unlet b:delimitMate_eol_marker " Expand iabbreviations iabb def ghi -call DMTest_pairs('', ["idef("], "ghi()") +" TODO not sure how to make this test work +call DMTest_pairs('', ["idef("], "ghi()", '', 1) iunabb def " "call DMTest_pairs('', "abc а\(", "abc (а")