arrow.nvim icon indicating copy to clipboard operation
arrow.nvim copied to clipboard

saved files keep disappearing from arrow list

Open Amleto opened this issue 1 year ago • 8 comments

My list(s) of saved files keeps getting cleared out - I will have 3,4,5 files in the ui one second, then the next time I open the ui the list is empty.

My lazy config is,

return {
  "otavioschwanck/arrow.nvim",
  event = "VeryLazy",
  opts = {
    show_icons = true,
    leader_key = ' h', -- Recommended to be a single key
    buffer_leader_key = ' m', -- Per Buffer Mappings
    window = {
      border = "rounded",
    },
  },

  config = function(_, opts)
    require('arrow').setup(opts)
    local linenr_settings = vim.api.nvim_get_hl(0, {name='LineNr', link=false})
    vim.api.nvim_set_hl(0, 'ArrowBookmarkSign', {bg=linenr_settings.bg, fg="#d093c7"})
  end
}

As you can see I will be using the default scope - I thought this should be cwd? I don't :cd once I'm in nvim.

It's a bit inconsistent when the list disappears. I'm wondering if there is some implicit link to git commit or something? feels like things go wrong after committing some files, but not certain on that

Amleto avatar Jun 04 '24 22:06 Amleto

Narrowed this down a bit - all I have to do is open neogit status and then exit the status. Arrow will then report "no files yet" when opening the UI.

If I restart nvim then the UI is populated with what I expect (until I look at neogit again)

Amleto avatar Jun 07 '24 13:06 Amleto

Maybe your working directory(cwd) is changed when open neogit try :=vim.uv.cwd()

xzbdmw avatar Jun 07 '24 18:06 xzbdmw

Yes, it is changed when in neogit status to the git repo root, but when neogit status buffer is closed then cwd() is the same as it was before opening neogit

Amleto avatar Jun 07 '24 22:06 Amleto

Why not keep you cwd the same as git root, arrow persist files by cwd by default, you can also make it persist by git root.

xzbdmw avatar Jun 07 '24 23:06 xzbdmw

Because I don't want it to be. E.g. for for working specifically within a subdir of the repo.

Amleto avatar Jun 08 '24 01:06 Amleto

From what I can tell, arrow doesn't correctly handle the case where :lcd is used, followed by a buffer change - the global state needs to be refreshed on BufEnter (not only BufReadPost)?

Amleto avatar Jun 09 '24 10:06 Amleto

I am having the same issue, any updates on this?

mayromr avatar Aug 25 '24 12:08 mayromr

I have made this work around to my perrsonal config

-- this hack removes the 'reload arrow state on DirChanged' autocmd to fix the bug
-- where it loads state for git root when opening NeogitStatus, but does not reload state
-- when leaving NeogitStatus
local autoc_id = vim.api.nvim_get_autocmds({group="arrow", event="DirChanged"})[1].id
if autoc_id then
  vim.api.nvim_del_autocmd(autoc_id)

  vim.api.nvim_create_autocmd({ "DirChanged" }, {
    callback = function ()
      local config = require("arrow.config")
      local persist = require("arrow.persist")
      local git = require("arrow.git")

      local file_name = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ":t")
      if file_name == "NeogitStatus" then
        return
      end
      git.refresh_git_branch()
      persist.load_cache_file()
      config.setState("save_key_cached", config.getState("save_key")())
    end,
    desc = "load cache file on DirChanged",
    group = "arrow",
  })

end

Amleto avatar Oct 16 '24 23:10 Amleto