From 1cf040c75dd23cba03c2e4171f92d9b0f826ac26 Mon Sep 17 00:00:00 2001 From: Rylee Randall Date: Fri, 19 Jul 2024 13:16:09 +1000 Subject: [PATCH] feat: restore previous tab when closing focus --- lua/true-zen/focus.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/true-zen/focus.lua b/lua/true-zen/focus.lua index faca84d..969c8ff 100644 --- a/lua/true-zen/focus.lua +++ b/lua/true-zen/focus.lua @@ -1,6 +1,7 @@ local M = {} M.running = false +M.prev_tabno = nil local cmd = vim.cmd local data = require("true-zen.utils.data") local echo = require("true-zen.utils.echo") @@ -12,6 +13,7 @@ function M.on() echo("there is only one window open", "error") return end + M.prev_tabno = vim.fn.tabpagenr() cmd("tab split") M.running = true @@ -22,6 +24,9 @@ function M.off() data.do_callback("focus", "close", "pre") cmd("tabclose") + if M.prev_tabno ~= nil then + vim.api.nvim_feedkeys(M.prev_tabno .. "gt", 'n', true) + end M.running = false data.do_callback("focus", "close", "pos")