From b018c73d7e2c0a09e2dcfe914454adb97a4c04b0 Mon Sep 17 00:00:00 2001 From: Cesar Guzman <88-8@live.com.mx> Date: Sun, 22 Jan 2023 18:37:08 -0600 Subject: [PATCH] Solution for issues 105 https://github.com/Pocco81/true-zen.nvim/issues/105 --- lua/true-zen/ataraxis.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lua/true-zen/ataraxis.lua b/lua/true-zen/ataraxis.lua index 0946e9c..88e2b7f 100644 --- a/lua/true-zen/ataraxis.lua +++ b/lua/true-zen/ataraxis.lua @@ -234,23 +234,24 @@ end function M.off() data.do_callback("ataraxis", "close", "pre") - local cursor_pos - if api.nvim_win_is_valid(win.main) then + if pcall(function() api.nvim_win_is_valid(win.main) end) and api.nvim_win_is_valid(win.main) then if win.main ~= api.nvim_get_current_win() then fn.win_gotoid(win.main) end cursor_pos = fn.getpos(".") + else + data.do_callback("ataraxis", "close", "pos") + return 1 -- already off end - cmd("only") - if fn.filereadable(fn.expand("%:p")) == 1 then - cmd("q") + pcall(function () pcall(cmd("q")) end) end + require("true-zen.minimalist").off() - - for k, v in pairs(original_opts) do + + for k, v in pairs(original_opts) do if k ~= "highlights" then o[k] = v end