From 0b2a9ae364c7dc2ddbc6f351e87b04178717be07 Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Sat, 2 Jun 2018 22:37:56 +0200 Subject: [PATCH] Spawn tmux fg job in bg window when height <= 0 When the requested height for a tmux split is 0 or less and that the spawned job will be able to call back, spawn the foreground job in a new background window, just as if it were a background job If no callback mechanism is available, use a split of -height lines --- autoload/dispatch/tmux.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/dispatch/tmux.vim b/autoload/dispatch/tmux.vim index 5bff3e5..8e20749 100644 --- a/autoload/dispatch/tmux.vim +++ b/autoload/dispatch/tmux.vim @@ -49,12 +49,12 @@ function! dispatch#tmux#make(request) abort let title = shellescape(get(a:request, 'title', get(a:request, 'compiler', 'make'))) let height = get(g:, 'dispatch_tmux_height', get(g:, 'dispatch_quickfix_height', 10)) - if get(a:request, 'background', 0) + if get(a:request, 'background', 0) || (height <= 0 && dispatch#has_callback()) let cmd = 'new-window -d -n '.title elseif has('gui_running') || empty($TMUX) || (!empty(''.session) && session !=# system('tmux display-message -p "#S"')[0:-2]) let cmd = 'new-window -n '.title else - let cmd = 'split-window -l '.height.' -d' + let cmd = 'split-window -l '.(height < 0 ? -height : height).' -d' endif let cmd .= ' ' . dispatch#shellescape('-P', '-t', session.':', 'exec ' . script)