aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHiPhish <hiphish@Aleksandars-iMac.local>2017-06-06 13:02:48 +0200
committerJustin M. Keyes <justinkz@gmail.com>2017-06-11 15:51:53 +0200
commit9f534f338adf4a56d17555dc5b2c02e9935f81cb (patch)
tree807974574ada6960b84a14ba0ceeed0704cff03f /src
parentd0ff2000b2a639f3bb0f70e37104b561dab05562 (diff)
downloadrneovim-9f534f338adf4a56d17555dc5b2c02e9935f81cb.tar.gz
rneovim-9f534f338adf4a56d17555dc5b2c02e9935f81cb.tar.bz2
rneovim-9f534f338adf4a56d17555dc5b2c02e9935f81cb.zip
mksession: Restore tab-local working directory #6859
The ':tcd' command is the first tab-specific command written to the file and it is wrapped inside an 'if has('nvim')' block to keep the session file compatible with Vim. Closes #6678
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_docmd.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index a0406cf418..af8845de87 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -8847,15 +8847,16 @@ makeopens (
*/
tab_firstwin = firstwin; /* first window in tab page "tabnr" */
tab_topframe = topframe;
- for (tabnr = 1;; ++tabnr) {
+ for (tabnr = 1;; tabnr++) {
+ tabpage_T *tp = find_tabpage(tabnr);
+ if (tp == NULL) {
+ break; // done all tab pages
+ }
+
int need_tabnew = false;
int cnr = 1;
if ((ssop_flags & SSOP_TABPAGES)) {
- tabpage_T *tp = find_tabpage(tabnr);
-
- if (tp == NULL)
- break; /* done all tab pages */
if (tp == curtab) {
tab_firstwin = firstwin;
tab_topframe = topframe;
@@ -8968,6 +8969,16 @@ makeopens (
if (nr > 1 && ses_winsizes(fd, restore_size, tab_firstwin) == FAIL)
return FAIL;
+ // Take care of tab-local working directories if applicable
+ if (tp->tp_localdir) {
+ if (fputs("if has('nvim') | tcd ", fd) < 0
+ || ses_put_fname(fd, tp->tp_localdir, &ssop_flags) == FAIL
+ || fputs(" | endif", fd) < 0
+ || put_eol(fd) == FAIL) {
+ return FAIL;
+ }
+ }
+
/* Don't continue in another tab page when doing only the current one
* or when at the last tab page. */
if (!(ssop_flags & SSOP_TABPAGES))