Skip to content

Commit f874f57

Browse files
committed
fix(actions): fail to set_buf when buffer is &modified and &bh=wipe
`:call nvim_buf_set_text(0, 0, 0, 0, 0, []) | FzfLua files`
1 parent 549baf0 commit f874f57

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

lua/fzf-lua/actions.lua

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,16 @@ local is_curbuf = function(buf, fullpath)
160160
end
161161

162162
---@param bufnr integer
163-
---@param will_replace_curbuf boolean
164163
---@return boolean? success
165-
local set_buf = function(bufnr, will_replace_curbuf)
164+
local set_buf = function(bufnr)
166165
-- wipe unnamed empty buffers (e.g. "new") on switch
167166
local bufhidden
168-
if will_replace_curbuf
169-
and vim.bo.buftype == ""
167+
if vim.bo.buftype == ""
170168
and vim.bo.filetype == ""
171169
and vim.api.nvim_buf_line_count(0) == 1
172170
and vim.api.nvim_buf_get_lines(0, 0, -1, false)[1] == ""
173171
and vim.api.nvim_buf_get_name(0) == ""
172+
and not vim.bo.modified
174173
then
175174
bufhidden = vim.bo.bufhidden
176175
vim.bo.bufhidden = "wipe"
@@ -248,7 +247,7 @@ M.vimcmd_entry = function(vimcmd, selected, opts, bufedit)
248247
if not entry.uri and not is_curbuf(entry.bufnr, fullpath) then
249248
-- error loading buffer or save dialog cancelled
250249
local buf = entry.bufnr or vim.fn.bufadd(relpath) or 0
251-
if buf == 0 or not set_buf(buf, not layoutcmd) then
250+
if buf == 0 or not set_buf(buf) then
252251
return utils.warn("Unable to add buffer %s", fullpath)
253252
end
254253
end

0 commit comments

Comments
 (0)