From 05edc3ee827c09dc0f172b538555c0205a60fa1a Mon Sep 17 00:00:00 2001 From: mwishoff Date: Tue, 5 Dec 2023 18:48:18 -0800 Subject: [PATCH] If out_data is empty then write empty json to harpoon.json. Then read it back into out_data. --- lua/harpoon/data.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/harpoon/data.lua b/lua/harpoon/data.lua index 9653564..c23f40c 100644 --- a/lua/harpoon/data.lua +++ b/lua/harpoon/data.lua @@ -58,6 +58,12 @@ local function read_data() end local out_data = path:read() + + if not out_data or out_data == '' then + write_data({}) + out_data = path:read() + end + local data = vim.json.decode(out_data) return data end