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 b6fb42e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 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,7 +197,7 @@ 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

Expand All @@ -206,7 +206,10 @@ end

local function changed_win(_, _)
-- 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()
last_win = vim.api.nvim_get_current_win()

return result
end


Expand Down

0 comments on commit b6fb42e

Please sign in to comment.