fix(picker_ui): handle 'winfixbuf' when opening selected file#426
Merged
dmtrKovalenko merged 1 commit intodmtrKovalenko:mainfrom Apr 29, 2026
Merged
fix(picker_ui): handle 'winfixbuf' when opening selected file#426dmtrKovalenko merged 1 commit intodmtrKovalenko:mainfrom
dmtrKovalenko merged 1 commit intodmtrKovalenko:mainfrom
Conversation
When the current window has 'winfixbuf' enabled (Neovim 0.10+), :edit fails with E1513. Detect this case in M.select's 'edit' branch and either retarget a suitable non-fixed window or fall back to :split. Also extend find_suitable_window to skip windows with 'winfixbuf'. Fixes the following error when invoking the picker from a winfixbuf-locked window: E1513: Cannot switch buffer. 'winfixbuf' is enabled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Selecting a file in the picker raises
E1513whenever the source window haswinfixbufenabled:M.select'seditbranch checks the current buffer'sbuftype/modifiable, but not the window-localwinfixbufoption.:h winfixbufis the documented mechanism (Neovim 0.10+) for pinning a window to its buffer; any code path that runs:editmust respect it, otherwise the picker becomes unusable from a pinned window.Why this isn't an obscure edge case
winfixbufis the official "pin this window" API, not a niche flag. It fires in realistic flows::set winfixbuf) to keep it as a reference while jumping around — and then opens the picker to look at something else.:mksession, auto-session, etc.) restorewinfixbuffrom a previous session.winfixbufon certain windows; if the picker'sfind_suitable_windowhappens to land on one of those windows, the same error fires even when the source window was a non-file buffer.Other pickers (e.g. Telescope, Snacks.picker) already handle
winfixbuffor this reason.Reproduction (minimal)
:edit any_file.lua:set winfixbufExpected: file opens. Actual:
E1513, file is not opened.Fix
window_has_winfixbuf(win)(pcall-guarded for Neovim < 0.10 where the option doesn't exist).find_suitable_window: skip windows wherewinfixbufis set, so we never redirect into a pinned window.M.select'seditbranch: treatwinfixbufon the current window like a non-modifiable buftype — tryfind_suitable_windowfirst; if no suitable window exists, fall back to:splitso the file still opens without clobbering the pinned window.Default path (no
winfixbufanywhere) is unchanged::editreplaces the current buffer as before.Test scenarios verified
winfixbuf→ edit replaces current buffer (regression check, default path unchanged)winfixbuf→ falls back to:split, original window keeps its pinned bufferwinfixbuf+ another normal window exists → switches to the normal window and:editwinfixbuf→ split fallback, no error:set nowinfixbufafter fix → behavior identical to default pathNotes
winfixbuf.pcallaroundnvim_get_option_value('winfixbuf', ...)keeps the patch safe on Neovim versions predating the option.