Mercurial > vim
diff src/window.c @ 27032:18cafa092e8d v8.2.4045
patch 8.2.4045: some global functions are only used in one file
Commit: https://github.com/vim/vim/commit/782b43d89473dac00e3a8e02224a8330b88dbfef
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sat Jan 8 18:43:40 2022 +0000
patch 8.2.4045: some global functions are only used in one file
Problem: Some global functions are only used in one file.
Solution: Make the functions static. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/9492)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 08 Jan 2022 19:45:03 +0100 |
parents | c9474ae175f4 |
children | 85f56e16da9b |
line wrap: on
line diff
--- a/src/window.c +++ b/src/window.c @@ -4735,6 +4735,54 @@ win_enter(win_T *wp, int undo_sync) } /* + * Used after making another window the current one: change directory if + * needed. + */ + static void +fix_current_dir(void) +{ +#ifdef FEAT_AUTOCHDIR + if (p_acd) + do_autochdir(); + else +#endif + if (curwin->w_localdir != NULL || curtab->tp_localdir != NULL) + { + char_u *dirname; + + // Window or tab has a local directory: Save current directory as + // global directory (unless that was done already) and change to the + // local directory. + if (globaldir == NULL) + { + char_u cwd[MAXPATHL]; + + if (mch_dirname(cwd, MAXPATHL) == OK) + globaldir = vim_strsave(cwd); + } + if (curwin->w_localdir != NULL) + dirname = curwin->w_localdir; + else + dirname = curtab->tp_localdir; + + if (mch_chdir((char *)dirname) == 0) + { + last_chdir_reason = NULL; + shorten_fnames(TRUE); + } + } + else if (globaldir != NULL) + { + // Window doesn't have a local directory and we are not in the global + // directory: Change to the global directory. + vim_ignored = mch_chdir((char *)globaldir); + VIM_CLEAR(globaldir); + last_chdir_reason = NULL; + shorten_fnames(TRUE); + } +} + +/* * Make window "wp" the current window. * Can be called with "flags" containing WEE_CURWIN_INVALID, which means that * curwin has just been closed and isn't valid. @@ -4859,54 +4907,6 @@ win_enter_ext(win_T *wp, int flags) } /* - * Used after making another window the current one: change directory if - * needed. - */ - void -fix_current_dir(void) -{ -#ifdef FEAT_AUTOCHDIR - if (p_acd) - do_autochdir(); - else -#endif - if (curwin->w_localdir != NULL || curtab->tp_localdir != NULL) - { - char_u *dirname; - - // Window or tab has a local directory: Save current directory as - // global directory (unless that was done already) and change to the - // local directory. - if (globaldir == NULL) - { - char_u cwd[MAXPATHL]; - - if (mch_dirname(cwd, MAXPATHL) == OK) - globaldir = vim_strsave(cwd); - } - if (curwin->w_localdir != NULL) - dirname = curwin->w_localdir; - else - dirname = curtab->tp_localdir; - - if (mch_chdir((char *)dirname) == 0) - { - last_chdir_reason = NULL; - shorten_fnames(TRUE); - } - } - else if (globaldir != NULL) - { - // Window doesn't have a local directory and we are not in the global - // directory: Change to the global directory. - vim_ignored = mch_chdir((char *)globaldir); - VIM_CLEAR(globaldir); - last_chdir_reason = NULL; - shorten_fnames(TRUE); - } -} - -/* * Jump to the first open window that contains buffer "buf", if one exists. * Returns a pointer to the window found, otherwise NULL. */