From b0dc352fa3bca147b6d846c45658e0d8c457e65c Mon Sep 17 00:00:00 2001 From: Rami Daghlawi Date: Fri, 13 Dec 2024 11:05:45 +0100 Subject: [PATCH] fix: create redraw function --- lua/kubectl/mappings.lua | 1 + lua/kubectl/views/init.lua | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lua/kubectl/mappings.lua b/lua/kubectl/mappings.lua index 917f2768..067bc478 100644 --- a/lua/kubectl/mappings.lua +++ b/lua/kubectl/mappings.lua @@ -292,6 +292,7 @@ function M.register() desc = "Toggle headers", callback = function() config.options.headers = not config.options.headers + pcall(require("kubectl.views").Redraw) end, }) diff --git a/lua/kubectl/views/init.lua b/lua/kubectl/views/init.lua index 893cee65..8dc5146d 100644 --- a/lua/kubectl/views/init.lua +++ b/lua/kubectl/views/init.lua @@ -214,6 +214,12 @@ function M.UserCmd(args) end) end +function M.Redraw() + local _, buf_name = pcall(vim.api.nvim_buf_get_var, 0, "buf_name") + local current_view, _ = M.view_and_definition(string.lower(vim.trim(buf_name))) + pcall(current_view.Draw) +end + --- Set a new URL and open the view ---@param opts table Options. Possible fields: --- - - Source view name where we are redirecting from