fix: edge case where cursor position was not set (#37)

This commit is contained in:
Steven Arcangeli 2023-01-18 00:21:04 -08:00
parent fb697752b2
commit 64d7763ac6
3 changed files with 47 additions and 2 deletions

View file

@ -1,4 +1,5 @@
require("plenary.async").tests.add_to_env()
local oil = require("oil")
local test_util = require("tests.test_util")
a.describe("regression tests", function()
@ -17,4 +18,17 @@ a.describe("regression tests", function()
a.util.sleep(10)
assert.equals("oil", vim.bo.filetype)
end)
-- https://github.com/stevearc/oil.nvim/issues/37
a.it("places the cursor on correct entry when opening on file", function()
vim.cmd.edit({ args = { "." } })
a.util.sleep(10)
local entry = oil.get_cursor_entry()
assert.not_equals("README.md", entry and entry.name)
vim.cmd.edit({ args = { "README.md" } })
oil.open()
a.util.sleep(10)
entry = oil.get_cursor_entry()
assert.equals("README.md", entry and entry.name)
end)
end)