forked from aniani/vim
updated for version 7.3.1099
Problem: Python: Changing directory with os.chdir() causes problems for Vim's notion of directories. Solution: Add vim.chdir() and vim.fchdir(). (ZyX)
This commit is contained in:
@@ -8182,6 +8182,37 @@ free_cd_dir()
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Deal with the side effects of changing the current directory.
|
||||
* When "local" is TRUE then this was after an ":lcd" command.
|
||||
*/
|
||||
void
|
||||
post_chdir(local)
|
||||
int local;
|
||||
{
|
||||
vim_free(curwin->w_localdir);
|
||||
if (local)
|
||||
{
|
||||
/* If still in global directory, need to remember current
|
||||
* directory as global directory. */
|
||||
if (globaldir == NULL && prev_dir != NULL)
|
||||
globaldir = vim_strsave(prev_dir);
|
||||
/* Remember this local directory for the window. */
|
||||
if (mch_dirname(NameBuff, MAXPATHL) == OK)
|
||||
curwin->w_localdir = vim_strsave(NameBuff);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We are now in the global directory, no need to remember its
|
||||
* name. */
|
||||
vim_free(globaldir);
|
||||
globaldir = NULL;
|
||||
curwin->w_localdir = NULL;
|
||||
}
|
||||
|
||||
shorten_fnames(TRUE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ":cd", ":lcd", ":chdir" and ":lchdir".
|
||||
@@ -8253,27 +8284,7 @@ ex_cd(eap)
|
||||
EMSG(_(e_failed));
|
||||
else
|
||||
{
|
||||
vim_free(curwin->w_localdir);
|
||||
if (eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir)
|
||||
{
|
||||
/* If still in global directory, need to remember current
|
||||
* directory as global directory. */
|
||||
if (globaldir == NULL && prev_dir != NULL)
|
||||
globaldir = vim_strsave(prev_dir);
|
||||
/* Remember this local directory for the window. */
|
||||
if (mch_dirname(NameBuff, MAXPATHL) == OK)
|
||||
curwin->w_localdir = vim_strsave(NameBuff);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We are now in the global directory, no need to remember its
|
||||
* name. */
|
||||
vim_free(globaldir);
|
||||
globaldir = NULL;
|
||||
curwin->w_localdir = NULL;
|
||||
}
|
||||
|
||||
shorten_fnames(TRUE);
|
||||
post_chdir(eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir);
|
||||
|
||||
/* Echo the new current directory if the command was typed. */
|
||||
if (KeyTyped || p_verbose >= 5)
|
||||
|
Reference in New Issue
Block a user