Skip to content

Commit

Permalink
Fix highlighting when swapping windows on error (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
MisanthropicBit authored Nov 20, 2024
1 parent 6b66a94 commit 5f06812
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lua/winmove/swap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ function swap.swap_window(win_id)
end

if not vim.api.nvim_win_is_valid(selected_window) then
highlight.unhighlight_window(selected_window)
selected_window = nil
message.error("Previously selected window is not valid anymore")
return
elseif win_id == selected_window then
highlight.unhighlight_window(selected_window)
selected_window = nil
message.error("Cannot swap selected window with itself")
return
Expand Down
1 change: 1 addition & 0 deletions tests/swap_window_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ describe("swap window", function()
.called_with("[winmove.nvim]: Cannot swap selected window with itself", vim.log.levels.ERROR)

assert.matches_winlayout(vim.fn.winlayout(), { "leaf", main_win_id })
assert.are.same(vim.wo[main_win_id].winhighlight, "")

---@diagnostic disable-next-line: undefined-field
vim.notify:revert()
Expand Down

0 comments on commit 5f06812

Please sign in to comment.