Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: restore previous tab when closing focus #132

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lua/true-zen/focus.lua
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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

Expand All @@ -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")
Expand Down