Exit copy-mode before running a command in the runner pane. Fixes #3

1.0.0rc1
benmills 12 years ago
parent d189f2b99c
commit c4a0836dfa

@ -91,18 +91,26 @@ class TmuxSession
end end
def inspect_runner def inspect_runner
run("select-pane -t #{target(:pane => runner_pane)}") _run("select-pane -t #{target(:pane => runner_pane)}")
run("copy-mode") _run("copy-mode")
Vim.command("let g:_VimTmuxInspecting = 1")
end
def stop_inspecting_runner
if Vim.evaluate('exists("g:_VimTmuxInspecting")') != 0
_run("send-keys -t #{target(:pane => runner_pane)} q")
Vim.command("unlet g:_VimTmuxInspecting")
end
end end
def current_panes def current_panes
run('list-panes').split("\n").map do |line| _run('list-panes').split("\n").map do |line|
line.split(':').first line.split(':').first
end end
end end
def active_pane_id def active_pane_id
run('list-panes').split("\n").map do |line| _run('list-panes').split("\n").map do |line|
return line.split[-2] if line =~ /\(active\)/ return line.split[-2] if line =~ /\(active\)/
end end
end end
@ -113,12 +121,12 @@ class TmuxSession
def runner_pane def runner_pane
if @runner_pane.nil? if @runner_pane.nil?
run("split-window -p #{height}") _run("split-window -p #{height}")
@runner_pane = active_pane_id @runner_pane = active_pane_id
Vim.command("let g:_VimTmuxRunnerPane = '#{@runner_pane}'") Vim.command("let g:_VimTmuxRunnerPane = '#{@runner_pane}'")
end end
run('list-panes').split("\n").map do |line| _run('list-panes').split("\n").map do |line|
return line.split(':').first if line =~ /#{@runner_pane}/ return line.split(':').first if line =~ /#{@runner_pane}/
end end
@ -128,30 +136,33 @@ class TmuxSession
end end
def interrupt_runner def interrupt_runner
run("send-keys -t #{target(:pane => runner_pane)} ^c") stop_inspecting_runner
_run("send-keys -t #{target(:pane => runner_pane)} ^c")
end end
def run_shell_command(command) def run_shell_command(command)
send_command(command, target(:pane => runner_pane)) stop_inspecting_runner
move_up_pane _send_command(command, target(:pane => runner_pane))
_move_up_pane
end end
def close_other_panes def close_other_panes
# if run("list-panes").split("\n").length > 1 stop_inspecting_runner
run("kill-pane -a") if _run("list-panes").split("\n").length > 1
# end _run("kill-pane -a")
end
end end
def move_up_pane def _move_up_pane
run("select-pane -t #{target}") _run("select-pane -t #{target}")
end end
def send_command(command, target) def _send_command(command, target)
run("send-keys -t #{target} '#{command.gsub("'", "\'")}'") _run("send-keys -t #{target} '#{command.gsub("'", "\'")}'")
run("send-keys -t #{target} Enter") _run("send-keys -t #{target} Enter")
end end
def run(command) def _run(command)
`tmux #{command}` `tmux #{command}`
end end
end end
@ -166,7 +177,7 @@ class CurrentTmuxSession < TmuxSession
end end
def get_property(match, type) def get_property(match, type)
run("list-#{type.to_s}").split("\n").each do |line| _run("list-#{type.to_s}").split("\n").each do |line|
return line.split(':').first if line =~ /\(#{match.to_s}\)/ return line.split(':').first if line =~ /\(#{match.to_s}\)/
end end
end end

Loading…
Cancel
Save