comparison src/ex_docmd.c @ 13170:6559e98f3e74 v8.0.1459

patch 8.0.1459: cannot handle change of directory commit https://github.com/vim/vim/commit/b7407d3fc9496f9048fb65ab17b5ba3444965c0e Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 3 17:36:27 2018 +0100 patch 8.0.1459: cannot handle change of directory Problem: Cannot handle change of directory. Solution: Add the DirChanged autocommand event. (Andy Massimino, closes #888) Avoid changing directory for 'autochdir' too often.
author Christian Brabandt <cb@256bit.org>
date Sat, 03 Feb 2018 17:45:05 +0100
parents a80082fd1a1d
children dc28351a85d4
comparison
equal deleted inserted replaced
13169:570e10c8313d 13170:6559e98f3e74
9046 #endif 9046 #endif
9047 if (new_dir == NULL || vim_chdir(new_dir)) 9047 if (new_dir == NULL || vim_chdir(new_dir))
9048 EMSG(_(e_failed)); 9048 EMSG(_(e_failed));
9049 else 9049 else
9050 { 9050 {
9051 post_chdir(eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir); 9051 int is_local_chdir = eap->cmdidx == CMD_lcd
9052 || eap->cmdidx == CMD_lchdir;
9053
9054 post_chdir(is_local_chdir);
9052 9055
9053 /* Echo the new current directory if the command was typed. */ 9056 /* Echo the new current directory if the command was typed. */
9054 if (KeyTyped || p_verbose >= 5) 9057 if (KeyTyped || p_verbose >= 5)
9055 ex_pwd(eap); 9058 ex_pwd(eap);
9059 #ifdef FEAT_AUTOCMD
9060 apply_autocmds(EVENT_DIRCHANGED,
9061 is_local_chdir ? (char_u *)"window" : (char_u *)"global",
9062 new_dir, FALSE, curbuf);
9063 #endif
9056 } 9064 }
9057 vim_free(tofree); 9065 vim_free(tofree);
9058 } 9066 }
9059 } 9067 }
9060 9068
9930 if (mch_dirname(dirnow, MAXPATHL) == FAIL 9938 if (mch_dirname(dirnow, MAXPATHL) == FAIL
9931 || mch_chdir((char *)dirnow) != 0) 9939 || mch_chdir((char *)dirnow) != 0)
9932 *dirnow = NUL; 9940 *dirnow = NUL;
9933 if (*dirnow != NUL && (ssop_flags & SSOP_SESDIR)) 9941 if (*dirnow != NUL && (ssop_flags & SSOP_SESDIR))
9934 { 9942 {
9935 if (vim_chdirfile(fname) == OK) 9943 if (vim_chdirfile(fname, NULL) == OK)
9936 shorten_fnames(TRUE); 9944 shorten_fnames(TRUE);
9937 } 9945 }
9938 else if (*dirnow != NUL 9946 else if (*dirnow != NUL
9939 && (ssop_flags & SSOP_CURDIR) && globaldir != NULL) 9947 && (ssop_flags & SSOP_CURDIR) && globaldir != NULL)
9940 { 9948 {