Skip to content

Commit

Permalink
fix: set buffer when using the smart open strategy
Browse files Browse the repository at this point in the history
refactor: remove deprecated api function usage
  • Loading branch information
willothy committed Dec 24, 2024
1 parent e049574 commit 45cd774
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lua/flatten/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,9 @@ function M.edit_files(opts)
bufnr = vim.fn.bufadd(fpath),
}

-- set buf options
if vim.api.nvim_set_option_value then
vim.api.nvim_set_option_value("buflisted", true, {
buf = file.bufnr,
})
else
---@diagnostic disable-next-line: deprecated
vim.api.nvim_buf_set_option(file.bufnr, "buflisted", true)
end
vim.api.nvim_set_option_value("buflisted", true, {
buf = file.bufnr,
})

files[i] = file
end
Expand Down Expand Up @@ -301,7 +295,10 @@ function M.edit_files(opts)
end
if open == "smart" then
local win = M.smart_open()
if not win then
if win then
vim.api.nvim_win_set_buf(win, focus.bufnr)
vim.api.nvim_set_current_win(win)
else
win = vim.api.nvim_open_win(focus.bufnr, true, {
vertical = false,
win = 0,
Expand Down

0 comments on commit 45cd774

Please sign in to comment.