Delete more variables on exit

This commit is contained in:
Shy 2017-03-29 20:47:08 +02:00
parent bb999c6e34
commit fc18301af4

View file

@ -12,7 +12,6 @@ if exists("g:loaded_c4ctrl")
endif
let g:loaded_c4ctrl = 1
let s:Name = "C4ctrl"
function s:FindConfigDir()
" Run only once
@ -154,11 +153,13 @@ endfunction
" Custom command line completion
function s:C4ctrlCompletion(ArgLead, CmdLine, CursorPos)
let s:Name = "C4ctrl"
" A list of current cmd line arguments excluding leading commands like
" :vertical etc.
let s:relCmdLine = split(a:CmdLine)
let s:relCmdLine = s:relCmdLine[index(s:relCmdLine, s:Name):]
try " Just for the clean up in the finally statement
if stridx("open", get(s:relCmdLine, 1)) == 0
if a:ArgLead != ""
return "open"
@ -205,14 +206,17 @@ function s:C4ctrlCompletion(ArgLead, CmdLine, CursorPos)
return join(map(glob(s:cfgdir."*", 0, 1), "fnamemodify(v:val, ':t')"), "\n")
elseif get(s:relCmdLine, -1) == s:Name
unlet s:relCmdLine
return "get\nopen\nset\ntext\nwrite"
else
return ""
endif
finally
unlet! s:relCmdLine s:Name s:cfgdir
endtry
endfunction
if !exists(":".s:Name)
execute "command -nargs=+ -complete=custom,s:C4ctrlCompletion" s:Name "call C4ctrl(<f-args>)"
if !exists(":C4ctrl")
command -nargs=+ -complete=custom,s:C4ctrlCompletion C4ctrl call C4ctrl(<f-args>)
endif