Solution: Add CheckNotOpenBSD, use it to skip certain tests
(Kevin Goodsell).
+Patch 9.1.2138
+Problem: With 'autochdir' win_execute() can corrupt the buffer name, causing
+ :write to use wrong path.
+Solution: Save and restore b_fname when 'autochdir' is active (Ingo Karkat).
+
vim:tw=78:ts=8:noet:ft=help:norl:fdm=manual:nofoldenable
# ifdef FEAT_AUTOCHDIR
char_u autocwd[MAXPATHL];
int apply_acd = FALSE;
+ char_u *save_sfname = NULL;
# endif
// Getting and setting directory can be slow on some systems, only do
// apply 'acd' afterwards, otherwise restore the current directory.
if (cwd_status == OK && p_acd)
{
+ if (curbuf->b_sfname != NULL && curbuf->b_fname == curbuf->b_sfname)
+ save_sfname = vim_strsave(curbuf->b_sfname);
do_autochdir();
apply_acd = mch_dirname(autocwd, MAXPATHL) == OK
&& STRCMP(cwd, autocwd) == 0;
restore_win_noblock(&switchwin, TRUE);
# ifdef FEAT_AUTOCHDIR
if (apply_acd)
+ {
+ vim_free(save_sfname);
do_autochdir();
+ }
else
# endif
if (cwd_status == OK)
+ {
mch_chdir((char *)cwd);
+# ifdef FEAT_AUTOCHDIR
+ if (save_sfname != NULL)
+ {
+ vim_free(curbuf->b_sfname);
+ curbuf->b_sfname = save_sfname;
+ curbuf->b_fname = curbuf->b_sfname;
+ }
+# endif
+ }
// Update the status line if the cursor moved.
if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor))
quit!
endfunc
+" Test that a temporary override of 'autochdir' via :lcd isn't clobbered by win_execute() in a split window.
+func Test_lcd_win_execute()
+ CheckOption autochdir
+
+ let startdir = getcwd()
+ call mkdir('Xsubdir', 'R')
+ call test_autochdir()
+ set autochdir
+ edit Xsubdir/file
+ call assert_match('testdir.Xsubdir.file$', expand('%:p'))
+ split
+ lcd ..
+ call assert_match('testdir.Xsubdir.file$', expand('%:p'))
+ call win_execute(win_getid(2), "")
+ call assert_match('testdir.Xsubdir.file$', expand('%:p'))
+
+ set noautochdir
+ bwipe!
+ call chdir(startdir)
+endfunc
+
func Test_cd_from_non_existing_dir()
CheckNotMSWindows