Giter Club home page Giter Club logo

Comments (12)

xolox avatar xolox commented on July 19, 2024

Your description is a bit ambiguous (from the perspective of the person who programmed the plug-in and thinks in very specific terms about what Vim and users do) so I'm not sure exactly what you expect the plug-in to do. Here's how it currently works:

  1. If you open Vim without specifying any filenames in the argument list on the command line the vim-session plug-in will attempt to load the default or last used session. If that session doesn't exist, nothing happens (no session is loaded).
  2. If you quit Vim while working in a loaded session, that session will be saved. If you quit Vim, automatic session saving is enabled and you haven't created any sessions yet, the plug-in will prompt you if you want to save the current (unnamed) session as the default session (this makes it easier to get started using the plug-in with the default session).

The behavior described above is currently the only "automagic" behavior in the vim-session plug-in (note that my description assumes the settings are left at their defaults). Everything else happens after an explicit action by the user. Does this help clear up any potential confusion? If not, and you insist the plug-in should be changed, then you'll need to be a lot more unambiguous in your wording (and convince me that the change is worth it ;-).

from vim-session.

xolox avatar xolox commented on July 19, 2024

Hmm maybe I should have read your description more carefully, you imply there is a bug in the periodic auto-save but without looking at the code I don't see how I could have missed that (I use the plug-in every day). I'll nevertheless take a look at the code to see if there are any corner cases involving quickly opening & quitting Vim.

from vim-session.

xolox avatar xolox commented on July 19, 2024

When I open a file without a session specified, make a quick edit and then close a file. I expect that when I start gvim with no parameters that it will start back up a default session with that file I was editing.

This does not appear to happen. An explicit SaveSession works great, but not the automatic save.

You say "open a file", but I suppose you mean you start Vim and edit a file in that empty Vim instance? And with "close a file" I suppose you mean you quit Vim? Before doing this, did a default session already exist or not?

from vim-session.

cthrax avatar cthrax commented on July 19, 2024

Sorry for the ambiguity, here's a clear series of steps to illustrate the issue:

  1. run 'vim file.ext'
  2. ":q"
  3. run 'vim'

My expectation after step 3 is that I will open up 'file.ext' in the same working directory as when I did step 2. Yes there is an existing default session. My expectation for this stems from setting 'g:session_autosave = 'yes''. Maybe I'm misunderstanding the description, but that seems to say that on quit, it will autosave the session. If it is different, maybe I can change this into a feature request :).

from vim-session.

xolox avatar xolox commented on July 19, 2024

If I put myself in your perspective I see what you expect, but coming back to my perspective as the maintainer of the plug-in I'm not sure if and how I would implement this for general use. The plug-in is not very creative with automatic session creation; It only proposes to create the default session if no sessions exist yet.

In the default configuration all sessions are stored together in a single directory, so they need a unique name. You mentioned you already have a default session, yet you expect the vim-session plug-in to automatically come up with a suitable unique session name for the session created in steps 1 and 2 of your example.

The simplest way to realize this would be to have sessions bound to directories. You can already do this by simply changing the location of the session directory (and optionally the name of the default session):

let g:session_directory = '.'
let g:session_default_name = 'session'

If you add the above Vim commands to your vimrc script, sessions will be bound to directories and saved as session.vim. Does that help? :-)

from vim-session.

cthrax avatar cthrax commented on July 19, 2024

There I go not speaking clearly again. My expectation is not for another session, just that the default session is overwritten with the new values. Or whatever session I'm running is overwritten. I apologize for the back and forth on this.

from vim-session.

xolox avatar xolox commented on July 19, 2024

If every Vim instance overwrites the default session, what happens when you start multiple instances of Vim at the same time?

(edit: with instance I mean process)

from vim-session.

cthrax avatar cthrax commented on July 19, 2024

I would expect last one in to win. I'm viewing the default session as the last-used session, and the named session as one you handle carefully, it appears that's not the intent from this discussion though.

from vim-session.

xolox avatar xolox commented on July 19, 2024

Changing this now would be a backwards incompatible change that would overwrite the default session of users when they wouldn't expect it (because previously it wouldn't have happened). I guess I can make it an option though, something like "session_default_overwrite" which is set to false by default but can be set to true.

from vim-session.

cthrax avatar cthrax commented on July 19, 2024

That'd be awesome! Thanks a lot man!

from vim-session.

xolox avatar xolox commented on July 19, 2024

I think the new version should do what you expect it to if you set the session_default_overwrite option. Can you confirm that it works?

from vim-session.

cthrax avatar cthrax commented on July 19, 2024

Works perfect! Thanks a lot for the quick turnaround and sorry it took me so long to test it out.

from vim-session.

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.