Giter VIP home page Giter VIP logo

Comments (8)

tummetott avatar tummetott commented on August 22, 2024 1

Did you open neovim with an argument? Or just neovim with no file as argument? For the latter, the Session file is crated, for the former not.

from persisted.nvim.

olimorris avatar olimorris commented on August 22, 2024

Thanks for raising this and your detailed minimal.lua file. Can confirm I can recreate this so will take a look at this in the coming days.

from persisted.nvim.

olimorris avatar olimorris commented on August 22, 2024

@tummetott I've created a new branch, fix/auto-creating-sessions. Could you check it out and test when you get a moment?

from persisted.nvim.

tummetott avatar tummetott commented on August 22, 2024

The issue persists. I've tested your branch, deleted the session files, but they are not automatically created. Furthermore, even when simply running nvim and then closing it, the session files are no longer generated.

from persisted.nvim.

olimorris avatar olimorris commented on August 22, 2024

I've misunderstood the initial issue then. Because using your minimal.lua file, I could open up Neovim in a directory with no session file, execute :q and see a session appear

from persisted.nvim.

olimorris avatar olimorris commented on August 22, 2024

Okay so just pushed a new feature to the branch. By default, no session should be created if autocreate = false (which it is by default).

from persisted.nvim.

tummetott avatar tummetott commented on August 22, 2024

Ok with autocreate = true, the session file is created. However now I get errors from time to time:

E5108: Error executing lua: ...hare/nvim/lazy/persistence.nvim/lua/persistence/init.lua:81: attempt to concatenate field 'dir' (a nil value)
stack traceback:
        ...hare/nvim/lazy/persistence.nvim/lua/persistence/init.lua:81: in function 'list'
        ...hare/nvim/lazy/persistence.nvim/lua/persistence/init.lua:19: in function 'get_last'
        ...hare/nvim/lazy/persistence.nvim/lua/persistence/init.lua:74: in function 'load'

In my opinion, introducing a new option called autocreate might lead to confusion for users. The expected behavior, when setting autosave = true, is that saving should occur automatically. However, with the proposed autocreate setting, it implies that saving will only work when both autosave and autocreate are set to true.

A more intuitive approach could be to change the behavior as follows: when autosave = true, session files are always created automatically because the user expects autosave to function seamlessly. If a different behavior is desired, such as saving only when session files were created before explicitly with :SessionSave, the option value autosave = "known_dir" (or another suitable name) could be introduced.

from persisted.nvim.

olimorris avatar olimorris commented on August 22, 2024

Following your steps to reproduce the bug, the issue comes down to this. If I remove this it means anytime someone opens up Neovim with an argument, it will automatically save the session...potentially overwriting an existing one.

Appreciate I've been dipping into this issue every couple of days and not given it some dedicated time but open to a PR which could resolve it.

from persisted.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.