File tree Expand file tree Collapse file tree 9 files changed +51
-4
lines changed Expand file tree Collapse file tree 9 files changed +51
-4
lines changed Original file line number Diff line number Diff line change @@ -1899,7 +1899,10 @@ do_autochdir(void)
1899
1899
if ((starting == 0 || test_autochdir )
1900
1900
&& curbuf -> b_ffname != NULL
1901
1901
&& vim_chdirfile (curbuf -> b_ffname , "auto" ) == OK )
1902
+ {
1902
1903
shorten_fnames (TRUE);
1904
+ last_chdir_reason = "autochdir" ;
1905
+ }
1903
1906
}
1904
1907
#endif
1905
1908
Original file line number Diff line number Diff line change @@ -7390,6 +7390,7 @@ changedir_func(
7390
7390
7391
7391
if (dir_differs )
7392
7392
{
7393
+ last_chdir_reason = NULL ;
7393
7394
if (scope == CDSCOPE_WINDOW )
7394
7395
acmd_fname = (char_u * )"window" ;
7395
7396
else if (scope == CDSCOPE_TABPAGE )
@@ -7453,7 +7454,9 @@ ex_pwd(exarg_T *eap UNUSED)
7453
7454
{
7454
7455
char * context = "global" ;
7455
7456
7456
- if (curwin -> w_localdir != NULL )
7457
+ if (last_chdir_reason != NULL )
7458
+ context = last_chdir_reason ;
7459
+ else if (curwin -> w_localdir != NULL )
7457
7460
context = "window" ;
7458
7461
else if (curtab -> tp_localdir != NULL )
7459
7462
context = "tabpage" ;
Original file line number Diff line number Diff line change @@ -832,6 +832,7 @@ EXTERN int stdout_isatty INIT(= TRUE); // is stdout a terminal?
832
832
#if defined(FEAT_AUTOCHDIR )
833
833
EXTERN int test_autochdir INIT (= FALSE);
834
834
#endif
835
+ EXTERN char * last_chdir_reason INIT (= NULL);
835
836
#if defined(EXITFREE )
836
837
EXTERN int entered_free_all_mem INIT (= FALSE);
837
838
// TRUE when in or after free_all_mem()
Original file line number Diff line number Diff line change 275
275
* Hint: to avoid this when typing a command use a forward slash.
276
276
* If the cd fails, it doesn't matter.
277
277
*/
278
- (void )vim_chdirfile (params .fname , "drop" );
278
+ if (vim_chdirfile (params .fname , "drop" ) == OK )
279
+ last_chdir_reason = "drop" ;
279
280
if (start_dir != NULL )
280
281
mch_dirname (start_dir , MAXPATHL );
281
282
}
Original file line number Diff line number Diff line change @@ -2656,7 +2656,10 @@ netbeans_file_opened(buf_T *bufp)
2656
2656
2657
2657
nb_send (buffer , "netbeans_file_opened" );
2658
2658
if (p_acd && vim_chdirfile (bufp -> b_ffname , "auto" ) == OK )
2659
+ {
2660
+ last_chdir_reason = "netbeans" ;
2659
2661
shorten_fnames (TRUE);
2662
+ }
2660
2663
}
2661
2664
2662
2665
/*
Original file line number Diff line number Diff line change @@ -7783,8 +7783,9 @@ fix_arg_enc(void)
7783
7783
if (curwin -> w_arg_idx == 0 && curbuf -> b_fname == NULL )
7784
7784
{
7785
7785
do_cmdline_cmd ((char_u * )":rewind" );
7786
- if (GARGCOUNT == 1 && used_file_full_path )
7787
- (void )vim_chdirfile (alist_name (& GARGLIST [0 ]), "drop" );
7786
+ if (GARGCOUNT == 1 && used_file_full_path
7787
+ && vim_chdirfile (alist_name (& GARGLIST [0 ]), "drop" ) == OK )
7788
+ last_chdir_reason = "drop" ;
7788
7789
}
7789
7790
7790
7791
set_alist_count ();
Original file line number Diff line number Diff line change @@ -25,4 +25,33 @@ func Test_set_filename()
25
25
call delete (' samples/Xtest' )
26
26
endfunc
27
27
28
+ func Test_verbose_pwd ()
29
+ let cwd = getcwd ()
30
+ call test_autochdir ()
31
+
32
+ edit global .txt
33
+ call assert_match (' \[global\].*testdir$' , execute (' verbose pwd' ))
34
+
35
+ call mkdir (' Xautodir' )
36
+ split Xautodir/local.txt
37
+ lcd Xautodir
38
+ call assert_match (' \[window\].*testdir[/\\]Xautodir' , execute (' verbose pwd' ))
39
+
40
+ set acd
41
+ wincmd w
42
+ call assert_match (' \[autochdir\].*testdir$' , execute (' verbose pwd' ))
43
+ wincmd w
44
+ call assert_match (' \[autochdir\].*testdir[/\\]Xautodir' , execute (' verbose pwd' ))
45
+ set noacd
46
+ call assert_match (' \[autochdir\].*testdir[/\\]Xautodir' , execute (' verbose pwd' ))
47
+ wincmd w
48
+ call assert_match (' \[global\].*testdir' , execute (' verbose pwd' ))
49
+ wincmd w
50
+ call assert_match (' \[window\].*testdir[/\\]Xautodir' , execute (' verbose pwd' ))
51
+
52
+ bwipe!
53
+ call chdir (cwd)
54
+ call delete (' Xautodir' , ' rf' )
55
+ endfunc
56
+
28
57
" vim: shiftwidth = 2 sts = 2 expandtab
Original file line number Diff line number Diff line change @@ -757,6 +757,8 @@ static char *(features[]) =
757
757
758
758
static int included_patches [] =
759
759
{ /* Add new patch number below this line */
760
+ /**/
761
+ 3617 ,
760
762
/**/
761
763
3616 ,
762
764
/**/
Original file line number Diff line number Diff line change @@ -4873,14 +4873,18 @@ fix_current_dir(void)
4873
4873
dirname = curtab -> tp_localdir ;
4874
4874
4875
4875
if (mch_chdir ((char * )dirname ) == 0 )
4876
+ {
4877
+ last_chdir_reason = NULL ;
4876
4878
shorten_fnames (TRUE);
4879
+ }
4877
4880
}
4878
4881
else if (globaldir != NULL )
4879
4882
{
4880
4883
// Window doesn't have a local directory and we are not in the global
4881
4884
// directory: Change to the global directory.
4882
4885
vim_ignored = mch_chdir ((char * )globaldir );
4883
4886
VIM_CLEAR (globaldir );
4887
+ last_chdir_reason = NULL ;
4884
4888
shorten_fnames (TRUE);
4885
4889
}
4886
4890
}
You can’t perform that action at this time.
0 commit comments