Ignore empty pane number in AttachToPane
Closes #23 - AttachToPane Ctrl-C interpreted as 0
This commit is contained in:
parent
4fdd883ce5
commit
457c189f16
@ -48,7 +48,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:RequireRunnerPane()
|
function! s:RequireRunnerPane()
|
||||||
if !exists("s:runner_pane")
|
if !exists("s:runner_pane")
|
||||||
echohl ErrorMsg | echom "VTR: No runner pane attached." | echohl None
|
call s:EchoError("VTR: No runner pane attached.")
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
return 1
|
return 1
|
||||||
@ -56,7 +56,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:RequireDetachedPane()
|
function! s:RequireDetachedPane()
|
||||||
if !exists("s:detached_window")
|
if !exists("s:detached_window")
|
||||||
echohl ErrorMsg | echom "VTR: No detached runner pane." | echohl None
|
call s:EchoError("VTR: No detached runner pane.")
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
return 1
|
return 1
|
||||||
@ -64,7 +64,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:RequireLocalPaneOrDetached()
|
function! s:RequireLocalPaneOrDetached()
|
||||||
if !exists('s:detached_window') && !exists('s:runner_pane')
|
if !exists('s:detached_window') && !exists('s:runner_pane')
|
||||||
echohl ErrorMsg | echom "VTR: No pane, local or detached." | echohl None
|
call s:EchoError("VTR: No pane, local or detached.")
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
return 1
|
return 1
|
||||||
@ -209,20 +209,31 @@ function! s:_ReattachPane()
|
|||||||
let s:runner_pane = s:ActiveTmuxPaneNumber()
|
let s:runner_pane = s:ActiveTmuxPaneNumber()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:AttachToPane()
|
function! s:PromptForRunnerToAttach()
|
||||||
if g:VtrDisplayPaneNumbers
|
if g:VtrDisplayPaneNumbers
|
||||||
call s:SendTmuxCommand('source ~/.tmux.conf && tmux display-panes')
|
call s:SendTmuxCommand('source ~/.tmux.conf && tmux display-panes')
|
||||||
endif
|
endif
|
||||||
echohl String | let desired_pane = input('Pane #: ') | echohl None
|
echohl String | let desired_pane = input('Pane #: ') | echohl None
|
||||||
let desired_pane = str2nr(desired_pane)
|
if desired_pane != ''
|
||||||
if s:ValidRunnerPaneNumber(desired_pane)
|
call s:AttachToPane(str2nr(desired_pane))
|
||||||
let s:runner_pane = desired_pane
|
|
||||||
echohl String | echo "\rRunner pane set to: " . desired_pane | echohl None
|
|
||||||
else
|
else
|
||||||
echohl ErrorMsg | echo "\rInvalid pane number: " . desired_pane | echohl None
|
call s:EchoError("No pane specified. Cancelling.")
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:AttachToPane(desired_pane)
|
||||||
|
if s:ValidRunnerPaneNumber(a:desired_pane)
|
||||||
|
let s:runner_pane = a:desired_pane
|
||||||
|
echohl String | echo "\rRunner pane set to: " . a:desired_pane | echohl None
|
||||||
|
else
|
||||||
|
call s:EchoError("Invalid pane number: " . a:desired_pane)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:EchoError(message)
|
||||||
|
echohl ErrorMsg | echo "\r". a:message | echohl None
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:ValidRunnerPaneNumber(desired_pane)
|
function! s:ValidRunnerPaneNumber(desired_pane)
|
||||||
if a:desired_pane == s:ActiveTmuxPaneNumber() | return 0 | endif
|
if a:desired_pane == s:ActiveTmuxPaneNumber() | return 0 | endif
|
||||||
if a:desired_pane > len(s:TmuxPanes()) | return 0 | endif
|
if a:desired_pane > len(s:TmuxPanes()) | return 0 | endif
|
||||||
@ -305,7 +316,7 @@ function! s:SendCommandToRunner(...)
|
|||||||
let escaped_empty_string = "''"
|
let escaped_empty_string = "''"
|
||||||
if s:user_command == escaped_empty_string
|
if s:user_command == escaped_empty_string
|
||||||
unlet s:user_command
|
unlet s:user_command
|
||||||
echohl ErrorMsg | echom "VTR: command string required" | echohl None
|
call s:EchoError("VTR: command string required")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
call s:EnsureRunnerPane()
|
call s:EnsureRunnerPane()
|
||||||
@ -397,7 +408,7 @@ function! s:DefineCommands()
|
|||||||
command! VtrClearRunner call s:SendClearSequence()
|
command! VtrClearRunner call s:SendClearSequence()
|
||||||
command! VtrFlushCommand call s:FlushCommand()
|
command! VtrFlushCommand call s:FlushCommand()
|
||||||
command! VtrSendCtrlD call s:SendCtrlD()
|
command! VtrSendCtrlD call s:SendCtrlD()
|
||||||
command! VtrAttachToPane call s:AttachToPane()
|
command! VtrAttachToPane call s:PromptForRunnerToAttach()
|
||||||
command! VtrZoomRunnerPane call s:ZoomRunnerPane()
|
command! VtrZoomRunnerPane call s:ZoomRunnerPane()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user