From 0cbd6b43d49102a11bd9192dc8beba679259b346 Mon Sep 17 00:00:00 2001
From: Jerome Reybert <jreybert@gmail.com>
Date: Tue, 23 May 2017 23:38:02 +0200
Subject: [PATCH] plugin/magit.vim: if opened with MagitOnly, 'q' shows
 previous buffer

I hope all the cases are well handled and it does break anything

fix #137
---
 plugin/magit.vim | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/plugin/magit.vim b/plugin/magit.vim
index 2cec897..6e36896 100644
--- a/plugin/magit.vim
+++ b/plugin/magit.vim
@@ -717,9 +717,9 @@ function! magit#show_magit(display, ...)
 	if ( magit_win != 0 )
 		silent execute magit_win."wincmd w"
 	elseif ( a:display == 'v' )
-		silent execute "vnew " . buffer_name
+		silent execute "keepalt vnew " . buffer_name
 	elseif ( a:display == 'h' )
-		silent execute "new " . buffer_name
+		silent execute "keepalt new " . buffer_name
 	elseif ( a:display == 'c' )
 		if ( !bufexists(buffer_name) )
 			if ( bufname("%") == "" )
@@ -836,11 +836,11 @@ endfunction
 
 function! magit#close_magit()
 	try
-		close
-	catch /^Vim\%((\a\+)\)\=:E444/
+		edit #
+	catch /^Vim\%((\a\+)\)\=:E\%(194\|499\)/
 		try
-			edit #
-		catch /^Vim\%((\a\+)\)\=:E\%(194\|499\)/
+			close
+		catch /^Vim\%((\a\+)\)\=:E444/
 			quit
 		endtry
 	endtry
-- 
GitLab