diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2025-02-05 23:09:29 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2025-02-05 23:09:29 +0000 |
commit | d5f194ce780c95821a855aca3c19426576d28ae0 (patch) | |
tree | d45f461b19f9118ad2bb1f440a7a08973ad18832 /test/functional/options/winfixbuf_spec.lua | |
parent | c5d770d311841ea5230426cc4c868e8db27300a8 (diff) | |
parent | 44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff) | |
download | rneovim-rahm.tar.gz rneovim-rahm.tar.bz2 rneovim-rahm.zip |
Diffstat (limited to 'test/functional/options/winfixbuf_spec.lua')
-rw-r--r-- | test/functional/options/winfixbuf_spec.lua | 74 |
1 files changed, 35 insertions, 39 deletions
diff --git a/test/functional/options/winfixbuf_spec.lua b/test/functional/options/winfixbuf_spec.lua index 124f194b5a..a01650ea71 100644 --- a/test/functional/options/winfixbuf_spec.lua +++ b/test/functional/options/winfixbuf_spec.lua @@ -1,55 +1,51 @@ local n = require('test.functional.testnvim')() +local t = require('test.testutil') local clear = n.clear local exec_lua = n.exec_lua -describe("Nvim API calls with 'winfixbuf'", function() +describe("'winfixbuf'", function() before_each(function() clear() end) - it("Calling vim.api.nvim_win_set_buf with 'winfixbuf'", function() - local results = exec_lua([[ - local function _setup_two_buffers() - local buffer = vim.api.nvim_create_buf(true, true) - - vim.api.nvim_create_buf(true, true) -- Make another buffer - - local current_window = 0 - vim.api.nvim_set_option_value("winfixbuf", true, {win=current_window}) - - return buffer - end - - local other_buffer = _setup_two_buffers() - local current_window = 0 - local results, _ = pcall(vim.api.nvim_win_set_buf, current_window, other_buffer) - - return results + ---@return integer + local function setup_winfixbuf() + return exec_lua([[ + local buffer = vim.api.nvim_create_buf(true, true) + vim.api.nvim_create_buf(true, true) -- Make another buffer + vim.wo.winfixbuf = true + return buffer ]]) - - assert(results == false) + end + + it('nvim_win_set_buf on non-current buffer', function() + local other_buf = setup_winfixbuf() + t.eq( + "Vim:E1513: Cannot switch buffer. 'winfixbuf' is enabled", + t.pcall_err(n.api.nvim_win_set_buf, 0, other_buf) + ) end) - it("Calling vim.api.nvim_set_current_buf with 'winfixbuf'", function() - local results = exec_lua([[ - local function _setup_two_buffers() - local buffer = vim.api.nvim_create_buf(true, true) - - vim.api.nvim_create_buf(true, true) -- Make another buffer - - local current_window = 0 - vim.api.nvim_set_option_value("winfixbuf", true, {win=current_window}) - - return buffer - end - - local other_buffer = _setup_two_buffers() - local results, _ = pcall(vim.api.nvim_set_current_buf, other_buffer) + it('nvim_set_current_buf on non-current buffer', function() + local other_buf = setup_winfixbuf() + t.eq( + "Vim:E1513: Cannot switch buffer. 'winfixbuf' is enabled", + t.pcall_err(n.api.nvim_set_current_buf, other_buf) + ) + end) - return results - ]]) + it('nvim_win_set_buf on current buffer', function() + setup_winfixbuf() + local curbuf = n.api.nvim_get_current_buf() + n.api.nvim_win_set_buf(0, curbuf) + t.eq(curbuf, n.api.nvim_get_current_buf()) + end) - assert(results == false) + it('nvim_set_current_buf on current buffer', function() + setup_winfixbuf() + local curbuf = n.api.nvim_get_current_buf() + n.api.nvim_set_current_buf(curbuf) + t.eq(curbuf, n.api.nvim_get_current_buf()) end) end) |