mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
fix(picker.actions): don't open a new tab if the current tab is empty. Closes #2461
This commit is contained in:
parent
aeedfdbb75
commit
4e2424eca7
1 changed files with 8 additions and 0 deletions
|
|
@ -59,6 +59,9 @@ function M.jump(picker, _, action)
|
||||||
and vim.api.nvim_buf_line_count(current_buf) == 1
|
and vim.api.nvim_buf_line_count(current_buf) == 1
|
||||||
and vim.api.nvim_buf_get_lines(current_buf, 0, -1, false)[1] == ""
|
and vim.api.nvim_buf_get_lines(current_buf, 0, -1, false)[1] == ""
|
||||||
and vim.api.nvim_buf_get_name(current_buf) == ""
|
and vim.api.nvim_buf_get_name(current_buf) == ""
|
||||||
|
local current_tab_windows = #vim.tbl_filter(function(w)
|
||||||
|
return not Snacks.util.is_float(w)
|
||||||
|
end, vim.api.nvim_tabpage_list_wins(current_tab))
|
||||||
|
|
||||||
if not current_empty then
|
if not current_empty then
|
||||||
-- save position in jump list
|
-- save position in jump list
|
||||||
|
|
@ -121,6 +124,11 @@ function M.jump(picker, _, action)
|
||||||
find_win(true)
|
find_win(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Don't open a new tab if current buffer is empty
|
||||||
|
if cmd == "tab sbuffer" and current_empty and current_tab_windows == 1 then
|
||||||
|
cmd = "buffer"
|
||||||
|
end
|
||||||
|
|
||||||
-- open the first buffer
|
-- open the first buffer
|
||||||
vim.cmd(("%s %d"):format(cmd, first_buf))
|
vim.cmd(("%s %d"):format(cmd, first_buf))
|
||||||
win = vim.api.nvim_get_current_win()
|
win = vim.api.nvim_get_current_win()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue