diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-04-07 18:16:10 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-04-07 18:16:10 +0200 |
commit | 9d956ee8eab64a0d412b045305fde5bc03d95d4a (patch) | |
tree | cf646584973d74b7d376f065c013d94667de7063 /src/autocmd.c | |
parent | a44ced5763d377c71c96562b894c1c026ba89328 (diff) |
patch 9.1.0272: autocmd may change cwd after :tcd and :lcdv9.1.0272
Problem: Autocommand may change currect directory after :tcd and :lcd.
Solution: Also clear tp_localdir and w_localdir when using aucmd_win.
(zeertzjq)
closes: #14435
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/autocmd.c')
-rw-r--r-- | src/autocmd.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/autocmd.c b/src/autocmd.c index b1c74cb853..666cf45d30 100644 --- a/src/autocmd.c +++ b/src/autocmd.c @@ -1660,6 +1660,11 @@ aucmd_prepbuf( win_init_popup_win(auc_win, buf); + // Make sure tp_localdir and globaldir are NULL to avoid a + // chdir() in win_enter_ext(). + // win_init_popup_win() has already set w_localdir to NULL. + aco->tp_localdir = curtab->tp_localdir; + curtab->tp_localdir = NULL; aco->globaldir = globaldir; globaldir = NULL; @@ -1773,6 +1778,12 @@ win_found: vars_clear(&awp->w_vars->dv_hashtab); // free all w: variables hash_init(&awp->w_vars->dv_hashtab); // re-use the hashtab #endif + // If :lcd has been used in the autocommand window, correct current + // directory before restoring tp_localdir and globaldir. + if (awp->w_localdir != NULL) + win_fix_current_dir(); + vim_free(curtab->tp_localdir); + curtab->tp_localdir = aco->tp_localdir; vim_free(globaldir); globaldir = aco->globaldir; |