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

auto-save clobbers marks #44

Closed
gegnew opened this issue Jan 11, 2024 · 9 comments
Closed

auto-save clobbers marks #44

gegnew opened this issue Jan 11, 2024 · 9 comments
Assignees

Comments

@gegnew
Copy link

gegnew commented Jan 11, 2024

yup, just that. auto-save removes all marks every time it runs.

Any way to avoid this?

Cheers!

@primeapple
Copy link
Collaborator

I just tried, for me marks stay. Please post your config and a reliable Steps To Reproduce.

It might be that you have other autocommands that depend on save events that are triggered by the auto save. In this case you might try noautocmd = true in your config.

@primeapple
Copy link
Collaborator

Any answer on this @gegnew ? Otherwise I'd like to close it.

@simonmandlik
Copy link

Hi @primeapple, I noticed that only [ and ] marks are removed (as was the case in the upstream)

Try this MWE:

local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

local plugins = {
    -- "okuuva/auto-save.nvim",
    -- opts = {},
}

require("lazy").setup(plugins, { root = root .. "/plugins", })

Try (un)commenting the two lines in plugins, deleting something in the middle of a buffer and then pressing '] and '[. It should take me to the changed lines, but when autosave is active, it takes me to the beginning and end of the buffer.

@primeapple
Copy link
Collaborator

Yeah, I can reproduce that.

To me it seems that the ] and [ marks get reset when saving the buffer. This also happens when manually saving via :w so that seems to be the bug (feature ;-)).

So if you find a way to get it working that manual saving doesn't clear the [ and ] marks I'm happy to implement it here. I tried noautocmd but no luck :(

@simonmandlik
Copy link

Perhaps use :lockmarks w instead of just :w? source

primeapple added a commit that referenced this issue Apr 19, 2024
@primeapple
Copy link
Collaborator

Opened a PR for this. I tested it locally and it seems to work. But please reassure yourself.

@primeapple primeapple self-assigned this Apr 19, 2024
primeapple added a commit that referenced this issue Apr 24, 2024
primeapple added a commit that referenced this issue Apr 25, 2024
Use `lockmarks` in write command to keep `[` and `]` marks after saving.

Thanks @simonmandlik

---------

Co-authored-by: okuuva <okuuva@users.noreply.github.com>
@primeapple
Copy link
Collaborator

Please confirm, that the commit changed it for you, then feel free to close @simonmandlik

@simonmandlik
Copy link

simonmandlik commented Apr 25, 2024

It did, thanks!

But I can't close, the issue is not mine

@okuuva
Copy link
Owner

okuuva commented Apr 25, 2024

Fixed in #53.

@okuuva okuuva closed this as completed Apr 25, 2024
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

4 participants