Skip to content

Commit

Permalink
plugin/magit.vim: better handling of magit buffer, including clean qu…
Browse files Browse the repository at this point in the history
…it command (fix #43)
  • Loading branch information
jreybert committed Nov 17, 2015
1 parent 795e280 commit 3d4f637
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions plugin/magit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,15 @@ function! magit#show_magit(display, ...)
return
endif
if ( a:display == 'v' )
vnew
vnew
elseif ( a:display == 'h' )
new
new
elseif ( a:display == 'c' )
enew
if ( bufname("%") == "" )
keepalt enew
else
enew
endif
else
throw 'parameter_error'
endif
Expand All @@ -603,19 +607,21 @@ function! magit#show_magit(display, ...)
let b:magit_default_fold_level = a:2
endif

if ( bufexists(g:magit_buffer_name) )
silent! execute "bdelete " . g:magit_buffer_name
endif
silent! execute "file " . g:magit_buffer_name

setlocal buftype=nofile
setlocal bufhidden=hide
setlocal noswapfile
setlocal foldmethod=syntax
setlocal nobuflisted
let &l:foldlevel = b:magit_default_fold_level
setlocal filetype=magit
"setlocal readonly

try
silent execute "buffer " . g:magit_buffer_name
catch /^Vim\%((\a\+)\)\=:E94/
silent execute "keepalt file " . g:magit_buffer_name
endtry

call magit#utils#setbufnr(bufnr(g:magit_buffer_name))
call magit#sign#init()

Expand Down

0 comments on commit 3d4f637

Please sign in to comment.