Prevent kill wrong background window
Closes #37 - Check for detached window title before killing
This commit is contained in:
parent
0a80e5bc67
commit
515f7d8730
@ -53,8 +53,25 @@ function! s:ValidRunnerPaneSet()
|
|||||||
return 1
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:DetachedWindowOutOfSync()
|
||||||
|
let window_map = s:WindowMap()
|
||||||
|
if index(keys(window_map), s:detached_window) == -1
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
if s:WindowMap()[s:detached_window] != g:VtrDetachedName
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
return 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:DetachedPaneAvailable()
|
function! s:DetachedPaneAvailable()
|
||||||
if !exists("s:detached_window")
|
if exists("s:detached_window")
|
||||||
|
if s:DetachedWindowOutOfSync()
|
||||||
|
call s:EchoError("Detached pane out of sync. Unable to kill")
|
||||||
|
unlet s:detached_window
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
else
|
||||||
call s:EchoError("No detached runner pane.")
|
call s:EchoError("No detached runner pane.")
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
@ -77,7 +94,18 @@ function! s:KillLocalRunner()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:WindowMap()
|
||||||
|
let window_pattern = '\v(\d+): ([-_a-zA-Z]{-})[-\* ]\s.*'
|
||||||
|
let window_map = {}
|
||||||
|
for line in split(s:SendTmuxCommand("list-windows"), "\n")
|
||||||
|
let dem = split(substitute(line, window_pattern, '\1:\2', ""), ':')
|
||||||
|
let window_map[dem[0]] = dem[1]
|
||||||
|
endfor
|
||||||
|
return window_map
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:KillDetachedWindow()
|
function! s:KillDetachedWindow()
|
||||||
|
if !s:DetachedPaneAvailable() | return | endif
|
||||||
let cmd = join(["kill-window", '-t', s:detached_window])
|
let cmd = join(["kill-window", '-t', s:detached_window])
|
||||||
call s:SendTmuxCommand(cmd)
|
call s:SendTmuxCommand(cmd)
|
||||||
unlet s:detached_window
|
unlet s:detached_window
|
||||||
|
Loading…
x
Reference in New Issue
Block a user