diff options
author | James McCoy <jamessan@jamessan.com> | 2021-12-20 14:28:11 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-20 14:28:11 -0500 |
commit | 9241c684e18d85205b1a6e4e4a33b187b78a7356 (patch) | |
tree | 5e4364934c842a3cae555e29f5e50db2be85b9ec /src/nvim/file_search.c | |
parent | 9625832372e77c8a15f6ebb30df4fcbb6aba6fe8 (diff) | |
parent | 09c412837fc9690ac8817dfd9c623dc6771c8d25 (diff) | |
download | rneovim-9241c684e18d85205b1a6e4e4a33b187b78a7356.tar.gz rneovim-9241c684e18d85205b1a6e4e4a33b187b78a7356.tar.bz2 rneovim-9241c684e18d85205b1a6e4e4a33b187b78a7356.zip |
Merge pull request #16734 from zeertzjq/chdir-refactor
refactor: remove some chdir-related unnecessary calls and checks
Diffstat (limited to 'src/nvim/file_search.c')
-rw-r--r-- | src/nvim/file_search.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c index d31021b3ef..1884dd49c5 100644 --- a/src/nvim/file_search.c +++ b/src/nvim/file_search.c @@ -1667,14 +1667,19 @@ int vim_chdirfile(char_u *fname, CdCause cause) NameBuff[0] = NUL; } - if (os_chdir(dir) == 0) { - if (cause != kCdCauseOther && pathcmp(dir, (char *)NameBuff, -1) != 0) { - do_autocmd_dirchanged(dir, kCdScopeWindow, cause); - } - } else { + if (pathcmp(dir, (char *)NameBuff, -1) == 0) { + // nothing to do + return OK; + } + + if (os_chdir(dir) != 0) { return FAIL; } + if (cause != kCdCauseOther) { + do_autocmd_dirchanged(dir, kCdScopeWindow, cause); + } + return OK; } |