Patch 8.2.3617
Problem:    ":verbose pwd" does not mention 'autochdir' was applied.
Solution:   Remember the last chdir was done by 'autochdir'.  (issue #9142)
Files:      src/globals.h, src/buffer.c, src/ex_docmd.c, src/window.c,
            src/main.c, src/netbeans.c, src/os_win32.c,
            src/testdir/test_autochdir.vim


*** ../vim-8.2.3616/src/globals.h       2021-10-24 20:34:01.434895238 +0100
--- src/globals.h       2021-11-18 18:11:23.827182827 +0000
***************
*** 832,837 ****
--- 832,838 ----
  #if defined(FEAT_AUTOCHDIR)
  EXTERN int    test_autochdir INIT(= FALSE);
  #endif
+ EXTERN char   *last_chdir_reason INIT(= NULL);
  #if defined(EXITFREE)
  EXTERN int    entered_free_all_mem INIT(= FALSE);
                                // TRUE when in or after free_all_mem()
*** ../vim-8.2.3616/src/buffer.c        2021-10-20 21:58:37.235792695 +0100
--- src/buffer.c        2021-11-18 18:10:29.607111980 +0000
***************
*** 1899,1905 ****
--- 1899,1908 ----
      if ((starting == 0 || test_autochdir)
            && curbuf->b_ffname != NULL
            && vim_chdirfile(curbuf->b_ffname, "auto") == OK)
+     {
        shorten_fnames(TRUE);
+       last_chdir_reason = "autochdir";
+     }
  }
  #endif
  
*** ../vim-8.2.3616/src/ex_docmd.c      2021-11-04 15:10:07.357074257 +0000
--- src/ex_docmd.c      2021-11-18 18:17:30.235343178 +0000
***************
*** 7390,7395 ****
--- 7390,7396 ----
  
        if (dir_differs)
        {
+           last_chdir_reason = NULL;
            if (scope == CDSCOPE_WINDOW)
                acmd_fname = (char_u *)"window";
            else if (scope == CDSCOPE_TABPAGE)
***************
*** 7453,7459 ****
        {
            char *context = "global";
  
!           if (curwin->w_localdir != NULL)
                context = "window";
            else if (curtab->tp_localdir != NULL)
                context = "tabpage";
--- 7454,7462 ----
        {
            char *context = "global";
  
!           if (last_chdir_reason != NULL)
!               context = last_chdir_reason;
!           else if (curwin->w_localdir != NULL)
                context = "window";
            else if (curtab->tp_localdir != NULL)
                context = "tabpage";
*** ../vim-8.2.3616/src/window.c        2021-11-14 11:41:27.264457621 +0000
--- src/window.c        2021-11-18 18:15:57.587344776 +0000
***************
*** 4873,4879 ****
--- 4873,4882 ----
            dirname = curtab->tp_localdir;
  
        if (mch_chdir((char *)dirname) == 0)
+       {
+           last_chdir_reason = NULL;
            shorten_fnames(TRUE);
+       }
      }
      else if (globaldir != NULL)
      {
***************
*** 4881,4886 ****
--- 4884,4890 ----
        // directory: Change to the global directory.
        vim_ignored = mch_chdir((char *)globaldir);
        VIM_CLEAR(globaldir);
+       last_chdir_reason = NULL;
        shorten_fnames(TRUE);
      }
  }
*** ../vim-8.2.3616/src/main.c  2021-07-20 20:07:32.964058857 +0100
--- src/main.c  2021-11-18 18:19:04.527320097 +0000
***************
*** 275,281 ****
         * Hint: to avoid this when typing a command use a forward slash.
         * If the cd fails, it doesn't matter.
         */
!       (void)vim_chdirfile(params.fname, "drop");
        if (start_dir != NULL)
            mch_dirname(start_dir, MAXPATHL);
      }
--- 275,282 ----
         * Hint: to avoid this when typing a command use a forward slash.
         * If the cd fails, it doesn't matter.
         */
!       if (vim_chdirfile(params.fname, "drop") == OK)
!           last_chdir_reason = "drop";
        if (start_dir != NULL)
            mch_dirname(start_dir, MAXPATHL);
      }
*** ../vim-8.2.3616/src/netbeans.c      2021-10-14 21:27:50.646253845 +0100
--- src/netbeans.c      2021-11-18 18:19:51.327301729 +0000
***************
*** 2656,2662 ****
--- 2656,2665 ----
  
      nb_send(buffer, "netbeans_file_opened");
      if (p_acd && vim_chdirfile(bufp->b_ffname, "auto") == OK)
+     {
+       last_chdir_reason = "netbeans";
        shorten_fnames(TRUE);
+     }
  }
  
  /*
*** ../vim-8.2.3616/src/os_win32.c      2021-11-01 22:44:29.517902113 +0000
--- src/os_win32.c      2021-11-18 18:20:37.835279449 +0000
***************
*** 7783,7790 ****
      if (curwin->w_arg_idx == 0 && curbuf->b_fname == NULL)
      {
        do_cmdline_cmd((char_u *)":rewind");
!       if (GARGCOUNT == 1 && used_file_full_path)
!           (void)vim_chdirfile(alist_name(&GARGLIST[0]), "drop");
      }
  
      set_alist_count();
--- 7783,7791 ----
      if (curwin->w_arg_idx == 0 && curbuf->b_fname == NULL)
      {
        do_cmdline_cmd((char_u *)":rewind");
!       if (GARGCOUNT == 1 && used_file_full_path
!               && vim_chdirfile(alist_name(&GARGLIST[0]), "drop") == OK)
!           last_chdir_reason = "drop";
      }
  
      set_alist_count();
*** ../vim-8.2.3616/src/testdir/test_autochdir.vim      2020-08-12 
17:50:31.871655841 +0100
--- src/testdir/test_autochdir.vim      2021-11-18 18:31:02.354727297 +0000
***************
*** 25,28 ****
--- 25,57 ----
    call delete('samples/Xtest')
  endfunc
  
+ func Test_verbose_pwd()
+   let cwd = getcwd()
+   call test_autochdir()
+ 
+   edit global.txt
+   call assert_match('\[global\].*testdir$', execute('verbose pwd'))
+ 
+   call mkdir('Xautodir')
+   split Xautodir/local.txt
+   lcd Xautodir
+   call assert_match('\[window\].*testdir[/\\]Xautodir', execute('verbose 
pwd'))
+ 
+   set acd
+   wincmd w
+   call assert_match('\[autochdir\].*testdir$', execute('verbose pwd'))
+   wincmd w
+   call assert_match('\[autochdir\].*testdir[/\\]Xautodir', execute('verbose 
pwd'))
+   set noacd
+   call assert_match('\[autochdir\].*testdir[/\\]Xautodir', execute('verbose 
pwd'))
+   wincmd w
+   call assert_match('\[global\].*testdir', execute('verbose pwd'))
+   wincmd w
+   call assert_match('\[window\].*testdir[/\\]Xautodir', execute('verbose 
pwd'))
+ 
+   bwipe!
+   call chdir(cwd)
+   call delete('Xautodir', 'rf')
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.3616/src/version.c       2021-11-18 15:37:24.286249010 +0000
--- src/version.c       2021-11-18 18:50:01.288850321 +0000
***************
*** 759,760 ****
--- 759,762 ----
  {   /* Add new patch number below this line */
+ /**/
+     3617,
  /**/

-- 
There can't be a crisis today, my schedule is already full.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211118185416.4D10D1C6567%40moolenaar.net.

Raspunde prin e-mail lui