Skip to content

Commit

Permalink
Merge pull request #322 from radlinskii/main
Browse files Browse the repository at this point in the history
ensure json is decoded correctly even if it's content is multiline
  • Loading branch information
rmagatti authored Jul 8, 2024
2 parents 04e1db5 + 567a5d2 commit 15586c4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lua/auto-session/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -671,15 +671,17 @@ local function write_to_session_control_json(session_file_name)
local session_control_file = control_dir .. control_file

local log_ending_state = function()
local content = vim.fn.readfile(session_control_file)
local file_lines = vim.fn.readfile(session_control_file)
local content = table.concat(file_lines, " ")
local session_control = vim.json.decode(content[1] or "{}") or {}
local sessions = { current = session_control.current, alternate = session_control.alternate }

Lib.logger.debug("session control file contents", { sessions = sessions, content = content })
end

if vim.fn.filereadable(session_control_file) == 1 then
local content = vim.fn.readfile(session_control_file)
local file_lines = vim.fn.readfile(session_control_file)
local content = table.concat(file_lines, " ")
Lib.logger.debug { content = content }
local json = vim.json.decode(content[1] or "{}") or {}

Expand Down

0 comments on commit 15586c4

Please sign in to comment.