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

Sessions don't restore tab-local directories #6678

Closed
mhinz opened this issue May 4, 2017 · 14 comments
Closed

Sessions don't restore tab-local directories #6678

mhinz opened this issue May 4, 2017 · 14 comments
Labels
bug issues reporting wrong behavior
Milestone

Comments

@mhinz
Copy link
Member

mhinz commented May 4, 2017

Window-local directories work already. Shouldn't be too hard to add tab-local support as well, if &sessionoptions contains tabpages.

@justinmk justinmk added the bug issues reporting wrong behavior label May 4, 2017
@justinmk justinmk added this to the todo milestone May 4, 2017
@justinmk
Copy link
Member

justinmk commented May 4, 2017

cc @HiPhish

@HiPhish
Copy link
Contributor

HiPhish commented May 4, 2017

I'll look into it over the weekend. My uneducated guess is that the file format of sessions does not store the working directory of tab pages since Vim does not have that information. Adding that information would (potentially) make sessions incompatible between Vim and Nvim, but I guess that's not a concern for us?

@chrisbra
Copy link
Contributor

chrisbra commented May 4, 2017

you can wrap it into has('nvim') conditionals.

@jamessan
Copy link
Member

jamessan commented May 4, 2017

Vim already has problems with portability of session files if you create one in a more featured Vim and then try to use it in a less featured Vim.

Using has('nvim') seems like a good approach.

@HiPhish
Copy link
Contributor

HiPhish commented May 4, 2017

Do you pointers as to where sessions are written and read? Otherwise I would have to go source-code diving blindly.

@jamessan
Copy link
Member

jamessan commented May 4, 2017

ex_mkrc() handles creating the session file. At startup, if a session file is specified (:help -S), Vim just runs :so /path/to/file.

@HiPhish
Copy link
Contributor

HiPhish commented May 4, 2017

OK, found the function. How do I do has('nvim') in C?

@jamessan
Copy link
Member

jamessan commented May 4, 2017

You don't. A session file is just a bunch of normal Vim commands, so you just wrap the :tcd related commands with if has('nvim').

@mhinz
Copy link
Member Author

mhinz commented Jun 1, 2017

@HiPhish *ping*

@HiPhish
Copy link
Contributor

HiPhish commented Jun 1, 2017

Sorry, I haven't forgotten, I just haven't yet had the time 😞

@HiPhish
Copy link
Contributor

HiPhish commented Jun 5, 2017

I have found the function of interest, it's makeopens in src/nvim/ex_docmd.c, this function is responsible for writing the bulk of the session file. Two questions:

  • Is it OK if I clean up the function a bit by changing the comments to our style? I.e. // instead of /* */, that way we save two lines per comment block and with a function this large that would be a benefit.
  • Where do I best insert the code?

There is this for-loop in the function:

  tab_firstwin = firstwin;      /* first window in tab page "tabnr" */
  tab_topframe = topframe;
  for (tabnr = 1;; ++tabnr) {

This seems like an appropriate place since it loop through all the tab pages (there is a check at the bottom for SSOP_TABPAGES). Does it matter where exactly the :tcd appears? I would have put it at the top before any window-specific options.

@justinmk
Copy link
Member

justinmk commented Jun 5, 2017

Does it matter where exactly the :tcd appears?

Whatever most closely matches the user expectations w.r.t. how tcd works.

I would have put it at the top before any window-specific options.

Seems reasonable.

Is :lcd restored...?

@HiPhish
Copy link
Contributor

HiPhish commented Jun 6, 2017

Is :lcd restored...?

Yes, that one is handled by the put_view function which is called for every window inside the tabpage loop. I think I got it now, but how and where should I write the test?

@HiPhish
Copy link
Contributor

HiPhish commented Jun 7, 2017

PR is up as RFC: #6859

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

No branches or pull requests

5 participants