mirror of
https://github.com/neovim/neovim.git
synced 2024-12-26 06:05:06 -07:00
141182d6c6
Problem: Cannot keep a buffer focused in a window
(Amit Levy)
Solution: Add the 'winfixbuf' window-local option
(Colin Kennedy)
fixes: vim/vim#6445
closes: vim/vim#13903
2157035637
N/A patch:
vim-patch:58f1e5c0893a
55 lines
1.5 KiB
Lua
55 lines
1.5 KiB
Lua
local helpers = require('test.functional.helpers')(after_each)
|
|
local clear = helpers.clear
|
|
local exec_lua = helpers.exec_lua
|
|
|
|
describe("Nvim API calls with '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
|
|
]])
|
|
|
|
assert(results == false)
|
|
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)
|
|
|
|
return results
|
|
]])
|
|
|
|
assert(results == false)
|
|
end)
|
|
end)
|