From 4e2424eca7ffaa6e36ebf4ac4d136d05b79edc41 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 6 Nov 2025 22:16:35 +0100 Subject: [PATCH] fix(picker.actions): don't open a new tab if the current tab is empty. Closes #2461 --- lua/snacks/picker/actions.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/snacks/picker/actions.lua b/lua/snacks/picker/actions.lua index bc3f4d70..372ae690 100644 --- a/lua/snacks/picker/actions.lua +++ b/lua/snacks/picker/actions.lua @@ -59,6 +59,9 @@ function M.jump(picker, _, action) 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_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 -- save position in jump list @@ -121,6 +124,11 @@ function M.jump(picker, _, action) find_win(true) 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 vim.cmd(("%s %d"):format(cmd, first_buf)) win = vim.api.nvim_get_current_win()