Skip to content

Commit

Permalink
Bug fixes (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
MisanthropicBit authored Aug 2, 2024
1 parent 70cff9c commit dbfd797
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lua/winmove/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ local function split_into(win_id, dir)
---@diagnostic disable-next-line:param-type-mismatch
if layout.are_siblings(win_id, target_win_id) then
---@diagnostic disable-next-line:param-type-mismatch
local reldir = layout.get_sibling_relative_dir(win_id, target_win_id, dir)
local reldir =
layout.get_sibling_relative_dir(win_id, target_win_id, dir, winmove.current_mode())

split_options.vertical = not split_options.vertical
split_options.rightbelow = reldir == "l" or reldir == "j"
Expand Down
4 changes: 3 additions & 1 deletion lua/winmove/layout.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local layout = {}

local winutil = require("winmove.winutil")
local Mode = require("winmove.mode")
local Mode = require("winmove.mode").Mode

---@class winmove.BoundingBox
---@field top integer
Expand Down Expand Up @@ -128,6 +128,8 @@ function layout.are_siblings(win_id1, win_id2)
end
end
end

return false
end

return _are_siblings(win_layout, nil, win_id1)
Expand Down
12 changes: 8 additions & 4 deletions tests/relative_cursor_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ describe("relative cursor", function()
})

vim.api.nvim_set_current_win(main_win_id)
winmove.move_window(main_win_id, "l")
winmove.start_mode(winmove.Mode.Move)
vim.cmd.normal("l")

assert.matches_winlayout(vim.fn.winlayout(), {
"row",
Expand Down Expand Up @@ -80,7 +81,8 @@ describe("relative cursor", function()
})

vim.api.nvim_set_current_win(main_win_id)
winmove.move_window(main_win_id, "l")
winmove.start_mode(winmove.Mode.Move)
vim.cmd.normal("l")

assert.matches_winlayout(vim.fn.winlayout(), {
"row",
Expand Down Expand Up @@ -132,7 +134,8 @@ describe("relative cursor", function()
})

vim.api.nvim_set_current_win(main_win_id)
winmove.move_window(main_win_id, "l")
winmove.start_mode(winmove.Mode.Move)
vim.cmd.normal("l")

assert.matches_winlayout(vim.fn.winlayout(), {
"row",
Expand Down Expand Up @@ -206,7 +209,8 @@ describe("relative cursor", function()
local long_line = ("x"):rep(width * 0.75)

vim.api.nvim_buf_set_lines(buffer, 0, 1, true, { long_line })
winmove.move_window(win_id, "k")
winmove.start_mode(winmove.Mode.Move)
vim.cmd.normal("k")

assert.matches_winlayout(vim.fn.winlayout(), {
"row",
Expand Down

0 comments on commit dbfd797

Please sign in to comment.