@@ -200,7 +200,7 @@ local can_replace_buf = function(buf)
200200 or not utils .buffer_is_dirty (buf , true , true )
201201end
202202
203- --- @param vimcmd string
203+ --- @param vimcmd string ?
204204--- @param selected string[]
205205--- @param opts fzf-lua.config.Resolved |{}
206206--- @param bufedit boolean ?
@@ -234,19 +234,21 @@ M.vimcmd_entry = function(vimcmd, selected, opts, bufedit)
234234 -- by neovim to "c:\app(web)" (#1082)
235235 local relpath = path .normalize (path .relative_to (fullpath , utils .cwd ()))
236236 if bufedit then
237- local will_replace_curbuf = # vimcmd == 0 and not is_curbuf ( entry . bufnr , fullpath )
238- if will_replace_curbuf and utils . wo . winfixbuf then
237+ local layoutcmd = not vimcmd and utils . wo . winfixbuf and " split " or vimcmd
238+ if layoutcmd ~= vimcmd then
239239 utils .warn (" 'winfixbuf' is set for current window, will open in a split." )
240- vimcmd , will_replace_curbuf = " split" , false
241240 end
242- if will_replace_curbuf and not can_replace_buf (0 ) then return end
243- if # vimcmd > 0 then vim .cmd (vimcmd ) end
241+ if layoutcmd then
242+ vim .cmd (layoutcmd )
243+ elseif not is_curbuf (entry .bufnr , fullpath ) and not can_replace_buf (0 ) then
244+ return utils .warn (" Unable to add buffer %s" , fullpath )
245+ end
244246 -- NOTE: URI entries only execute new buffers (new|vnew|tabnew)
245247 -- and later use `utils.jump_to_location` to load the buffer
246248 if not entry .uri and not is_curbuf (entry .bufnr , fullpath ) then
247249 -- error loading buffer or save dialog cancelled
248250 local buf = entry .bufnr or vim .fn .bufadd (relpath ) or 0
249- if buf == 0 or not set_buf (buf , will_replace_curbuf ) then
251+ if buf == 0 or not set_buf (buf , not layoutcmd ) then
250252 return utils .warn (" Unable to add buffer %s" , fullpath )
251253 end
252254 end
284286
285287-- file actions
286288M .file_edit = function (selected , opts )
287- M .vimcmd_entry (" " , selected , opts , true )
289+ M .vimcmd_entry (nil , selected , opts , true )
288290end
289291
290292M .file_split = function (selected , opts )
0 commit comments