fix(api): nvim_win_set_buf(0, 0) fails if 'winfixbuf' is set #31576

## Problem
With 'winfixbuf' enabled, `nvim_win_set_buf` and `nvim_set_current_buf` fail
even if targeting the already-current buffer.

    vim.wo.winfixbuf = true
    vim.api.nvim_win_set_buf(0, 0)
    vim.api.nvim_set_current_buf(0)

Solution:
Check for this condition.
This commit is contained in:
phanium
2024-12-16 16:59:24 +08:00
committed by GitHub
parent cc38630d39
commit 01a97d2ad7
3 changed files with 30 additions and 12 deletions

View File

@@ -888,7 +888,7 @@ void nvim_set_current_buf(Buffer buffer, Error *err)
{
buf_T *buf = find_buffer_by_handle(buffer, err);
if (!buf) {
if (!buf || curwin->w_buffer == buf) {
return;
}