From 571e43938096e043ea3d088e4ee817729d6841d8 Mon Sep 17 00:00:00 2001 From: Marco Kellershoff Date: Mon, 15 Jul 2024 21:30:24 +0200 Subject: [PATCH] fix(autocmd): add augroup --- lua/kulala/globals/init.lua | 2 +- lua/kulala/ui/init.lua | 4 +++- package.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/kulala/globals/init.lua b/lua/kulala/globals/init.lua index 5472ab3c..aecb02ea 100644 --- a/lua/kulala/globals/init.lua +++ b/lua/kulala/globals/init.lua @@ -2,7 +2,7 @@ local FS = require("kulala.utils.fs") local M = {} -M.VERSION = "2.2.1" +M.VERSION = "2.2.2" M.UI_ID = "kulala://ui" M.HEADERS_FILE = FS.get_plugin_tmp_dir() .. "/headers.txt" M.BODY_FILE = FS.get_plugin_tmp_dir() .. "/body.txt" diff --git a/lua/kulala/ui/init.lua b/lua/kulala/ui/init.lua index 98e27885..11f46959 100644 --- a/lua/kulala/ui/init.lua +++ b/lua/kulala/ui/init.lua @@ -34,7 +34,9 @@ end -- Create an autocmd to delete the buffer when the window is closed -- This is necessary to prevent the buffer from being left behind -- when the window is closed +local augroup = vim.api.nvim_create_augroup("kulala_window_closed", { clear = true }) vim.api.nvim_create_autocmd("WinClosed", { + group = augroup, callback = function(args) -- if the window path is the same as the GLOBALS.UI_ID and the buffer exists if args.buf == get_buffer() then @@ -114,7 +116,7 @@ M.show_headers = function() open_buffer() end local h = FS.read_file(GLOBALS.HEADERS_FILE) - h = h:gsub('\r\n', '\n') + h = h:gsub("\r\n", "\n") set_buffer_contents(h, "plaintext") else vim.notify("No headers found", vim.log.levels.WARN) diff --git a/package.json b/package.json index aa5afc4d..8430b386 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,4 @@ { "name": "kulala.nvim", - "version": "2.2.1" + "version": "2.2.2" }