Skip to content

Commit

Permalink
Make changed_win() also set last_win.
Browse files Browse the repository at this point in the history
  • Loading branch information
rish987 committed Jul 26, 2021
1 parent 20ce933 commit 882a875
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lua/tests/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ local function created_win(_, arguments)
if new_wins then
assert.update_wins(arguments[1], nil)
else
assert.changed_win()
assert.are_not.equal(last_win, vim.api.nvim_get_current_win())
assert.update_wins({vim.api.nvim_get_current_win()}, nil)
end

Expand All @@ -197,16 +197,19 @@ local function closed_win(_, arguments)
else
-- inductive hypothesis: in addition to that of update_wins,
-- last_win must be the window we were in immediately before closing
assert.changed_win()
assert.are_not.equal(last_win, vim.api.nvim_get_current_win())
assert.update_wins(nil, {last_win})
end

return true
end

local function changed_win(_, _)
local function changed_win(state, _)
-- no nested assertion to allow for negation
return last_win ~= vim.api.nvim_get_current_win()
local result = last_win ~= vim.api.nvim_get_current_win()
if state.mod and result then last_win = vim.api.nvim_get_current_win() end

return result
end


Expand Down

0 comments on commit 882a875

Please sign in to comment.