Commit b0532460 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Add a specific win ID argument to toggleterm toggle()

Adds a new optional argument to kodo#toggleterm#Terminal.toggle() which
specifies a window to check for the terminal buffer, and if not found
there, expand into it.
parent 6f0f345a
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -85,11 +85,20 @@ function! kodo#toggleterm#Terminal(new_win, ...)
		let self.window = v:null
	endfunction

	function term.toggle()
		if self.window == win_getid()
	" Collapse the terminal if expanded and vice-versa
	"
	" Terminal.toggle()
	" Terminal.toggle(window: window-ID)
	"
	" If a window is provided, check for the terminal in that window, otherwise 
	" check in the current window. If the terminal is expanded any specified 
	" window will also be passed as the window to expand into.
	function term.toggle(...)
		let window = get(a:, 1, win_getid())
		if self.window == window
			call self.collapse()
		else
			call self.expand()
			call call(self.expand, a:000)
		endif
	endfunction