diff --git a/plugin/magit.vim b/plugin/magit.vim index 60dc9c151972aa5c4b8c8709e462ffb4d2964a02..28311d05d569033197a5fe33d8c643278c0aa764 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -629,7 +629,7 @@ function! magit#show_magit(display, ...) execute "nnoremap <buffer> <silent> " . g:magit_commit_amend_mapping . " :call magit#commit_command('CA')<cr>" execute "nnoremap <buffer> <silent> " . g:magit_commit_fixup_mapping . " :call magit#commit_command('CF')<cr>" execute "nnoremap <buffer> <silent> " . g:magit_ignore_mapping . " :call magit#ignore_file()<cr>" - execute "nnoremap <buffer> <silent> " . g:magit_close_mapping . " :close<cr>" + execute "nnoremap <buffer> <silent> " . g:magit_close_mapping . " :call magit#close_magit()<cr>" execute "nnoremap <buffer> <silent> " . g:magit_toggle_help_mapping . " :call magit#toggle_help()<cr>" execute "nnoremap <buffer> <silent> " . g:magit_stage_line_mapping . " :call magit#stage_vselect()<cr>" @@ -654,6 +654,18 @@ function! magit#show_magit(display, ...) execute "normal! gg" endfunction +function! magit#close_magit() + try + close + catch /^Vim\%((\a\+)\)\=:E444/ + try + edit # + catch /^Vim\%((\a\+)\)\=:E194/ + quit + endtry + endtry +endfunction + function! s:mg_stage_closed_file(discard) if ( getline(".") =~ g:magit_file_re ) let list = matchlist(getline("."), g:magit_file_re)