LCOV - code coverage report
Current view: top level - /lua/yoda - session.lua (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 10 10
Test Date: 2026-04-14 10:33:13 Functions: - 0 0

            Line data    Source code
       1              : -- lua/yoda/session.lua
       2              : -- Session lifecycle: clean exit and state persistence.
       3              : --
       4              : -- WHY this module exists: Neovim's built-in SHADA write on exit can produce
       5              : -- "file already exists" warnings when a previous session left a stale temp file
       6              : -- (.shada.tmp.X) behind after a crash. Calling `wshada!` explicitly in
       7              : -- VimLeavePre forces an overwrite *before* Neovim's built-in exit write runs,
       8              : -- reducing the likelihood of those warnings. The pcall guard ensures a failing
       9              : -- write (read-only filesystem, permission denied) produces a WARN notification
      10              : -- rather than a confusing error message at quit time.
      11              : 
      12            4 : local M = {}
      13              : 
      14            4 : function M.setup()
      15           10 :   vim.api.nvim_create_autocmd("VimLeavePre", {
      16            5 :     group = vim.api.nvim_create_augroup("YodaSessionCleanup", { clear = true }),
      17              :     desc = "Force-write ShaDa on exit to prevent 'file already exists' warnings",
      18              :     callback = function()
      19            2 :       local ok, err = pcall(vim.cmd, "wshada!")
      20            2 :       if not ok then
      21            1 :         vim.notify("[yoda] ShaDa write failed: " .. tostring(err), vim.log.levels.WARN)
      22              :       end
      23            7 :     end,
      24              :   })
      25            9 : end
      26              : 
      27            4 : return M
        

Generated by: LCOV version 2.0-1