Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saved files keep disappearing from arrow list #68

Open
Amleto opened this issue Jun 4, 2024 · 8 comments
Open

saved files keep disappearing from arrow list #68

Amleto opened this issue Jun 4, 2024 · 8 comments

Comments

@Amleto
Copy link

Amleto commented Jun 4, 2024

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
Copy link
Author

Amleto commented Jun 7, 2024

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)

@xzbdmw
Copy link
Contributor

xzbdmw commented Jun 7, 2024

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

@Amleto
Copy link
Author

Amleto commented Jun 7, 2024

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

@xzbdmw
Copy link
Contributor

xzbdmw commented Jun 7, 2024

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.

@Amleto
Copy link
Author

Amleto commented Jun 8, 2024

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

@Amleto
Copy link
Author

Amleto commented Jun 9, 2024

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)?

@nhruo123
Copy link

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

@Amleto
Copy link
Author

Amleto commented Oct 16, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants