Hi!

I am using vim-latex on a project with a main file including several sections 
from files in a folder sections/.
If I call <leader>ll while editing sections/foo.tex, vim-latex will return from 
compilation correctly but also set cwd to sections/. This is unexpected 
behavior for me. I would not expect compilation to suddenly change the working 
directory.

I dug into the source code and came to the following conclusion:
s:origdir is used throughout the source code to save the cwd at the beginning 
of a function and later restore it. Unfortunately, s:origdir is a script-local 
variable. Therefore, reusing the method of "save cwd to s:origdir and restore" 
will not work if calls of functions using this method are nested. 

This is exactly the source of my unexpected change of cwd after compilation.
tex_RunLaTeX saves the correct cwd to s:origdir. It then changes the working 
directory. This is followed by calling tex_CompileLaTex() at some point, which 
will save the wrong cwd again to s:origdir and thus overrides the old, but 
correct cwd. By extension, the final restore of cwd at the end of tex_RunLaTeX 
will then restore the the incorrect directory, which in my case is the 
subdirectory sections/.

As a simple solution, I propose to substitute s:origdir with l:origdir or 
simply origdir as I see no compelling reason to make origdir a script-local 
variable. A simple "%s/s:origdir/l:origdir/g" on 
ftplugin/latex-suite/compiler.vim solved the original issue for me. It also 
appears to be used in main.vim, texproject.vim, and texviewer.vim. The same fix 
will probably apply there as well.

Is there any way I can contribute a pull-request or something alike?

Best,

Kai. (kaihowl)
------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Vim-latex-devel mailing list
Vim-latex-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vim-latex-devel

Reply via email to