aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/window.c
diff options
context:
space:
mode:
authorHiPhish <hiphish@Aleksandars-iMac.local>2015-08-24 12:58:28 +0200
committerHiPhish <hiphish@Aleksandars-iMac.local>2016-04-20 12:52:31 +0200
commitec71d87b8140ae097158f7e219b26701aed8158e (patch)
treeed9420d1d76c3b2ece7be3f8d89333604aa049f7 /src/nvim/window.c
parenta7a0bf54e3f339f7bf1f97dee44546cdcd926b1d (diff)
downloadrneovim-ec71d87b8140ae097158f7e219b26701aed8158e.tar.gz
rneovim-ec71d87b8140ae097158f7e219b26701aed8158e.tar.bz2
rneovim-ec71d87b8140ae097158f7e219b26701aed8158e.zip
Implement tab-local working directory feature.
New ex commands: 'tcd', 'tchdir' Changed Vimscript functions: 'haslocaldir', 'getcwd' The ex-commands ':tcd' and ':tchdir' are the tab-local equivalents of ':lcd' and ':lchdir'. There are no new Vimscript functions introduced, instead the functions 'haslocaldir' and 'getcwd' take in optional arguments. See the documentation for details Since there is now different levels of local directory a simple boolean at source level is no longer sufficient; a new enumeration type is used for the scope-level from now on. The documentation has been accommodated for these new commands and functional tests have been written to test the feature.
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r--src/nvim/window.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 1b8c953596..93a7a58678 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -2948,7 +2948,7 @@ void free_tabpage(tabpage_T *tp)
unref_var_dict(tp->tp_vars);
-
+ xfree(tp->localdir); // Free tab-local working directory
xfree(tp);
}
@@ -3560,18 +3560,24 @@ static void win_enter_ext(win_T *wp, bool undo_sync, int curwin_invalid, int tri
curwin->w_cursor.coladd = 0;
changed_line_abv_curs(); /* assume cursor position needs updating */
- if (curwin->w_localdir != NULL) {
- /* Window has a local directory: Save current directory as global
- * directory (unless that was done already) and change to the local
- * directory. */
+ // The new directory is either the local directory of the window, of the tab
+ // or NULL.
+ char_u *new_dir = curwin->w_localdir ? curwin->w_localdir : curtab->localdir;
+
+ if (new_dir) {
+ // Window/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 (os_dirname(cwd, MAXPATHL) == OK)
+ if (os_dirname(cwd, MAXPATHL) == OK) {
globaldir = vim_strsave(cwd);
+ }
+ }
+ if (os_chdir((char *)new_dir) == 0) {
+ shorten_fnames(true);
}
- if (os_chdir((char *)curwin->w_localdir) == 0)
- 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. */