comparison src/ex_docmd.c @ 4704:542af01979be v7.3.1099

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)
author Bram Moolenaar <bram@vim.org>
date Sun, 02 Jun 2013 18:20:17 +0200
parents 9b800f0a757f
children 1c5da99d1b70
comparison
equal deleted inserted replaced
4703:2d9d2b3b10b8 4704:542af01979be
8180 vim_free(globaldir); 8180 vim_free(globaldir);
8181 globaldir = NULL; 8181 globaldir = NULL;
8182 } 8182 }
8183 #endif 8183 #endif
8184 8184
8185 /*
8186 * Deal with the side effects of changing the current directory.
8187 * When "local" is TRUE then this was after an ":lcd" command.
8188 */
8189 void
8190 post_chdir(local)
8191 int local;
8192 {
8193 vim_free(curwin->w_localdir);
8194 if (local)
8195 {
8196 /* If still in global directory, need to remember current
8197 * directory as global directory. */
8198 if (globaldir == NULL && prev_dir != NULL)
8199 globaldir = vim_strsave(prev_dir);
8200 /* Remember this local directory for the window. */
8201 if (mch_dirname(NameBuff, MAXPATHL) == OK)
8202 curwin->w_localdir = vim_strsave(NameBuff);
8203 }
8204 else
8205 {
8206 /* We are now in the global directory, no need to remember its
8207 * name. */
8208 vim_free(globaldir);
8209 globaldir = NULL;
8210 curwin->w_localdir = NULL;
8211 }
8212
8213 shorten_fnames(TRUE);
8214 }
8215
8185 8216
8186 /* 8217 /*
8187 * ":cd", ":lcd", ":chdir" and ":lchdir". 8218 * ":cd", ":lcd", ":chdir" and ":lchdir".
8188 */ 8219 */
8189 void 8220 void
8251 #endif 8282 #endif
8252 if (new_dir == NULL || vim_chdir(new_dir)) 8283 if (new_dir == NULL || vim_chdir(new_dir))
8253 EMSG(_(e_failed)); 8284 EMSG(_(e_failed));
8254 else 8285 else
8255 { 8286 {
8256 vim_free(curwin->w_localdir); 8287 post_chdir(eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir);
8257 if (eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir)
8258 {
8259 /* If still in global directory, need to remember current
8260 * directory as global directory. */
8261 if (globaldir == NULL && prev_dir != NULL)
8262 globaldir = vim_strsave(prev_dir);
8263 /* Remember this local directory for the window. */
8264 if (mch_dirname(NameBuff, MAXPATHL) == OK)
8265 curwin->w_localdir = vim_strsave(NameBuff);
8266 }
8267 else
8268 {
8269 /* We are now in the global directory, no need to remember its
8270 * name. */
8271 vim_free(globaldir);
8272 globaldir = NULL;
8273 curwin->w_localdir = NULL;
8274 }
8275
8276 shorten_fnames(TRUE);
8277 8288
8278 /* Echo the new current directory if the command was typed. */ 8289 /* Echo the new current directory if the command was typed. */
8279 if (KeyTyped || p_verbose >= 5) 8290 if (KeyTyped || p_verbose >= 5)
8280 ex_pwd(eap); 8291 ex_pwd(eap);
8281 } 8292 }