From be87050b21f417ae29d0a270b5a295997a818306 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Tue, 7 Oct 2025 18:30:48 -0700 Subject: [PATCH 1/7] Use -a to list all panes across all sessions and windows --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index b5000a7..0640e03 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -356,7 +356,7 @@ function! s:hasRunner() abort return v:false endif let l:runnerType = VimuxOption('VimuxRunnerType') - let l:command = 'list-'.runnerType."s -F '#{".runnerType."_id}'" + let l:command = 'list-'.runnerType."s -a -F '#{".runnerType."_id}'" let l:found = match(VimuxTmux(l:command), g:VimuxRunnerIndex) return l:found != -1 endfunction From 7ced014fbed702005462c49eced4c782c3183e46 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Mon, 13 Oct 2025 21:40:34 -0700 Subject: [PATCH 2/7] Only set the runner index when opened Always uses the pane ID, so we can track the runner across windows and sessions --- plugin/vimux.vim | 44 ++++++++------------------------------------ 1 file changed, 8 insertions(+), 36 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 0640e03..7eaef0a 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -110,7 +110,7 @@ function! VimuxOpenRunner() abort elseif VimuxOption('VimuxRunnerType') ==# 'window' call VimuxTmux('new-window '.extraArguments) endif - let g:VimuxRunnerIndex = s:tmuxIndex() + let g:VimuxRunnerIndex = s:tmuxProperty('#{pane_id}') call s:setRunnerName() call VimuxTmux('last-'.VimuxOption('VimuxRunnerType')) endif @@ -128,15 +128,9 @@ function! VimuxTogglePane() abort if VimuxOption('VimuxRunnerType') ==# 'window' call VimuxTmux('join-pane -s '.g:VimuxRunnerIndex.' '.s:vimuxPaneOptions()) let g:VimuxRunnerType = 'pane' - let g:VimuxRunnerIndex = s:tmuxIndex() call VimuxTmux('last-'.VimuxOption('VimuxRunnerType')) elseif VimuxOption('VimuxRunnerType') ==# 'pane' - let g:VimuxRunnerIndex=substitute( - \ VimuxTmux('break-pane -d -s '.g:VimuxRunnerIndex." -P -F '#{window_id}'"), - \ '\n', - \ '', - \ '' - \) + call VimuxTmux('break-pane -d -s '.g:VimuxRunnerIndex) let g:VimuxRunnerType = 'window' endif else @@ -245,26 +239,6 @@ function! s:exitCopyMode() abort endtry endfunction -function! s:tmuxSession() abort - return s:tmuxProperty('#S') -endfunction - -function! s:tmuxIndex() abort - if VimuxOption('VimuxRunnerType') ==# 'pane' - return s:tmuxPaneId() - else - return s:tmuxWindowId() - end -endfunction - -function! s:tmuxPaneId() abort - return s:tmuxProperty('#{pane_id}') -endfunction - -function! s:tmuxWindowId() abort - return s:tmuxProperty('#{window_id}') -endfunction - function! s:vimuxPaneOptions() abort let height = VimuxOption('VimuxHeight') let orientation = VimuxOption('VimuxOrientation') @@ -272,8 +246,8 @@ function! s:vimuxPaneOptions() abort endfunction "" -" @return a string of the form '%4', the ID of the pane or window to use, -" or '' if no nearest pane or window is found. +" @return a string of the form '%4', the ID of the pane to use, +" or '' if no nearest pane is found. function! s:existingRunnerId() abort let runnerType = VimuxOption('VimuxRunnerType') let query = get(VimuxOption('VimuxRunnerQuery'), runnerType, '') @@ -285,12 +259,11 @@ function! s:existingRunnerId() abort endif endif " Try finding the runner using the provided query - let currentId = s:tmuxIndex() + let currentId = s:tmuxProperty('#{pane_id}') let message = VimuxTmux('select-'.runnerType.' -t '.query.'') if message ==# '' - " A match was found. Make sure it isn't the current vim pane/window - " though! - let runnerId = s:tmuxIndex() + " A match was found. Make sure it isn't the current vim pane! + let runnerId = s:tmuxProperty('#{pane_id}') if runnerId !=# currentId " Success! call VimuxTmux('last-'.runnerType) @@ -355,8 +328,7 @@ function! s:hasRunner() abort if get(g:, 'VimuxRunnerIndex', '') ==? '' return v:false endif - let l:runnerType = VimuxOption('VimuxRunnerType') - let l:command = 'list-'.runnerType."s -a -F '#{".runnerType."_id}'" + let l:command = "list-panes -a -F '#{pane_id}'" let l:found = match(VimuxTmux(l:command), g:VimuxRunnerIndex) return l:found != -1 endfunction From dca7cf660d6797c06d78e45c52aa821c868b9481 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Mon, 13 Oct 2025 22:14:38 -0700 Subject: [PATCH 3/7] Match the whole runner ID --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 7eaef0a..a68cd8a 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -329,7 +329,7 @@ function! s:hasRunner() abort return v:false endif let l:command = "list-panes -a -F '#{pane_id}'" - let l:found = match(VimuxTmux(l:command), g:VimuxRunnerIndex) + let l:found = match(VimuxTmux(l:command), g:VimuxRunnerIndex.'\>') return l:found != -1 endfunction From a2a0a1bdda15d3be5d46aa8aba31f7e599109ddf Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Mon, 13 Oct 2025 22:50:16 -0700 Subject: [PATCH 4/7] Use last-pane when we know the type is 'pane' --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index a68cd8a..f6a223b 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -128,7 +128,7 @@ function! VimuxTogglePane() abort if VimuxOption('VimuxRunnerType') ==# 'window' call VimuxTmux('join-pane -s '.g:VimuxRunnerIndex.' '.s:vimuxPaneOptions()) let g:VimuxRunnerType = 'pane' - call VimuxTmux('last-'.VimuxOption('VimuxRunnerType')) + call VimuxTmux('last-pane') elseif VimuxOption('VimuxRunnerType') ==# 'pane' call VimuxTmux('break-pane -d -s '.g:VimuxRunnerIndex) let g:VimuxRunnerType = 'window' From 69092c81e626a97fe3b1e5a99888ca6e6bf7a850 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Mon, 13 Oct 2025 23:00:44 -0700 Subject: [PATCH 5/7] Make sure the proper window + pane is selected --- plugin/vimux.vim | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index f6a223b..1db8a78 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -140,11 +140,8 @@ endfunction function! VimuxZoomRunner() abort if s:hasRunner() - if VimuxOption('VimuxRunnerType') ==# 'pane' - call VimuxTmux('resize-pane -Z -t '.g:VimuxRunnerIndex) - elseif VimuxOption('VimuxRunnerType') ==# 'window' - call VimuxTmux('select-window -t '.g:VimuxRunnerIndex) - endif + call s:selectRunner() + call VimuxTmux('resize-pane -Z -t '.g:VimuxRunnerIndex) else call s:echoNoRunner() endif @@ -152,7 +149,7 @@ endfunction function! VimuxInspectRunner() abort if s:hasRunner() - call VimuxTmux('select-'.VimuxOption('VimuxRunnerType').' -t '.g:VimuxRunnerIndex) + call s:selectRunner() call VimuxTmux('copy-mode') return v:true endif @@ -228,6 +225,11 @@ function! VimuxTmux(arguments) abort endif endfunction +function! s:selectRunner() abort + call VimuxTmux('select-window -t '.g:VimuxRunnerIndex) + call VimuxTmux('select-pane -t '.g:VimuxRunnerIndex) +endfunction + function! s:exitCopyMode() abort try call VimuxTmux('copy-mode -q -t '.g:VimuxRunnerIndex) @@ -308,6 +310,8 @@ function! s:getTargetFilter() abort endfunction function! s:setRunnerName() abort + " To be called only while the runner is active, including its window and + " session let targetName = VimuxOption('VimuxRunnerName') if targetName ==# '' return From 202031626bc33d7aae84229bd590e27af79399a5 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Tue, 21 Oct 2025 19:43:36 -0700 Subject: [PATCH 6/7] Fix VimuxCloseRunner() --- plugin/vimux.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 1db8a78..a9fad0b 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -118,7 +118,7 @@ endfunction function! VimuxCloseRunner() abort if s:hasRunner() - call VimuxTmux('kill-'.VimuxOption('VimuxRunnerType').' -t '.g:VimuxRunnerIndex) + call VimuxTmux('kill-pane -t '.g:VimuxRunnerIndex) endif unlet! g:VimuxRunnerIndex endfunction From 515584f8739a28591287d0ef09cd84e24c754cf2 Mon Sep 17 00:00:00 2001 From: Michael van der Kamp Date: Tue, 21 Oct 2025 19:56:53 -0700 Subject: [PATCH 7/7] Remove s:setRunnerName() --- plugin/vimux.vim | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/plugin/vimux.vim b/plugin/vimux.vim index a9fad0b..80549ca 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -111,7 +111,10 @@ function! VimuxOpenRunner() abort call VimuxTmux('new-window '.extraArguments) endif let g:VimuxRunnerIndex = s:tmuxProperty('#{pane_id}') - call s:setRunnerName() + let targetName = VimuxOption('VimuxRunnerName') + if targetName !=# '' + call VimuxTmux('select-pane -T '.targetName) + endif call VimuxTmux('last-'.VimuxOption('VimuxRunnerType')) endif endfunction @@ -283,7 +286,7 @@ function! s:nearestRunnerId() abort let views = split( \ VimuxTmux( \ 'list-'.runnerType.'s' - \ ." -F '#{".runnerType.'_active}:#{'.runnerType."_id}'" + \ ." -F '#{".runnerType.'_active}:#{pane_id}"' \ .filter), \ '\n') " '1:' is the current active pane (the one with vim). @@ -309,21 +312,6 @@ function! s:getTargetFilter() abort endif endfunction -function! s:setRunnerName() abort - " To be called only while the runner is active, including its window and - " session - let targetName = VimuxOption('VimuxRunnerName') - if targetName ==# '' - return - endif - let runnerType = VimuxOption('VimuxRunnerType') - if runnerType ==# 'window' - call VimuxTmux('rename-window '.targetName) - elseif runnerType ==# 'pane' - call VimuxTmux('select-pane -T '.targetName) - endif -endfunction - function! s:tmuxProperty(property) abort return substitute(VimuxTmux("display -p '".a:property."'"), '\n$', '', '') endfunction