Skip to content

Commit b2f5093

Browse files
deathbeamaserowy
andauthored
fix: disable navigation when in command window mode (#135)
* fix: disable navigation when in command window mode Prevents navigation from being triggered while in command window mode, which could lead to unexpected behavior. This ensures navigation commands only work in normal buffer windows. Closes #113 Signed-off-by: Tomas Slusny <[email protected]> * Fix formatting Signed-off-by: Tomas Slusny <[email protected]> --------- Signed-off-by: Tomas Slusny <[email protected]> Co-authored-by: Alexander Serowy <[email protected]>
1 parent 03e6225 commit b2f5093

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

lua/tmux/navigation/navigate.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ function M.to(direction)
1414
layout.has_tmux_target(direction, options.navigation.persist_zoom, options.navigation.cycle_navigation)
1515
if (nvim.is_nvim_float() or is_nvim_border) and has_tmux_target then
1616
tmux.change_pane(direction)
17-
elseif is_nvim_border and options.navigation.cycle_navigation then
18-
nvim.wincmd(nvim.opposite_direction(direction), 999)
19-
elseif not is_nvim_border then
20-
nvim.wincmd(direction, vim.v.count)
17+
elseif vim.fn.getcmdwintype() == "" then -- if not in command mode
18+
if is_nvim_border and options.navigation.cycle_navigation then
19+
nvim.wincmd(nvim.opposite_direction(direction), 999)
20+
elseif not is_nvim_border then
21+
nvim.wincmd(direction, vim.v.count)
22+
end
2123
end
2224
end
2325

spec/tmux/navigation/navigate_spec.lua

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ describe("navigate.to", function()
1919
tmux = require("tmux.wrapper.tmux")
2020

2121
_G.vim = { v = { count = 1 } }
22+
_G.vim.fn = {
23+
getcmdwintype = function()
24+
return ""
25+
end,
26+
}
2227
end)
2328

2429
it("check with no nvim borders", function()
@@ -171,4 +176,33 @@ describe("navigate.to", function()
171176
navigate.to("l")
172177
assert.are.same("l", last_called_direction)
173178
end)
179+
180+
it("check no navigation in command mode", function()
181+
_G.vim.fn = {
182+
getcmdwintype = function()
183+
return "="
184+
end,
185+
}
186+
options.navigation.cycle_navigation = false
187+
layout.has_tmux_target = function()
188+
return false
189+
end
190+
nvim.is_nvim_border = function()
191+
return false
192+
end
193+
nvim.is_nvim_float = function()
194+
return false
195+
end
196+
197+
local last_called_direction = ""
198+
nvim.wincmd = function(direction)
199+
last_called_direction = direction
200+
end
201+
202+
navigate.to("h")
203+
assert.are.same("", last_called_direction)
204+
205+
navigate.to("l")
206+
assert.are.same("", last_called_direction)
207+
end)
174208
end)

0 commit comments

Comments
 (0)