Commits

Meikel Brandmeyer  committed 1cc797a

Close result buffer in case it's the wrong type

Fixes #86

  • Participants
  • Parent commits c626ed5

Comments (0)

Files changed (1)

File vim/autoload/vimclojure.vim

 
 function! vimclojure#ResultBuffer.New(...) dict
 	if g:vimclojure#ResultBuffer.__instance != []
-		let closure = {
-					\ 'instance' : g:vimclojure#ResultBuffer.__instance[0],
-					\ 'args'     : a:000
-					\ 'f'        : function("ClojureResultBufferNewWorker")
-					\ }
+		let oldInstance = g:vimclojure#ResultBuffer.__instance[0]
 
-		return vimclojure#util#WithSavedOption('switchbuf', closure)
+		if oldInstance.prototype is self
+			let closure = {
+						\ 'instance' : oldInstance,
+						\ 'args'     : a:000,
+						\ 'f'        : function("ClojureResultBufferNewWorker")
+						\ }
+
+			return vimclojure#util#WithSavedOption('switchbuf', closure)
+		else
+			call oldInstance.close()
+		endif
 	endif
 
 	let b:vimclojure_result_buffer = 1