summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0149
blob: af951193b5d235f5ec28654d16de8c1893b896ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0149
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0149
Problem:    The generated sessions file does not restore tabs properly if :lcd
            was used in one of them.
Solution:   Create the tab pages before setting the directory. (Yee Cheng
            Chin, closes #3152)
Files:	    src/ex_docmd.c, src/testdir/test_mksession.vim


*** ../vim-8.1.0148/src/ex_docmd.c	2018-06-21 22:10:04.404854396 +0200
--- src/ex_docmd.c	2018-07-04 22:21:20.461625002 +0200
***************
*** 5491,5497 ****
  ex_autocmd(exarg_T *eap)
  {
      /*
!      * Disallow auto commands from .exrc and .vimrc in current
       * directory for security reasons.
       */
      if (secure)
--- 5491,5497 ----
  ex_autocmd(exarg_T *eap)
  {
      /*
!      * Disallow autocommands from .exrc and .vimrc in current
       * directory for security reasons.
       */
      if (secure)
***************
*** 11080,11089 ****
  #endif
  
      /*
!      * Close all windows but one.
       */
      if (put_line(fd, "silent only") == FAIL)
  	return FAIL;
  
      /*
       * Now a :cd command to the session directory or the current directory
--- 11080,11092 ----
  #endif
  
      /*
!      * Close all windows and tabs but one.
       */
      if (put_line(fd, "silent only") == FAIL)
  	return FAIL;
+     if ((ssop_flags & SSOP_TABPAGES)
+ 	    && put_line(fd, "silent tabonly") == FAIL)
+ 	return FAIL;
  
      /*
       * Now a :cd command to the session directory or the current directory
***************
*** 11193,11201 ****
       */
      tab_firstwin = firstwin;	/* first window in tab page "tabnr" */
      tab_topframe = topframe;
      for (tabnr = 1; ; ++tabnr)
      {
! 	int	need_tabnew = FALSE;
  	int	cnr = 1;
  
  	if ((ssop_flags & SSOP_TABPAGES))
--- 11196,11228 ----
       */
      tab_firstwin = firstwin;	/* first window in tab page "tabnr" */
      tab_topframe = topframe;
+     if ((ssop_flags & SSOP_TABPAGES))
+     {
+ 	int	num_tabs;
+ 
+ 	/*
+ 	 * Similar to ses_win_rec() below, populate the tab pages first so
+ 	 * later local options won't be copied to the new tabs.
+ 	 */
+ 	for (tabnr = 1; ; ++tabnr)
+ 	{
+ 	    tabpage_T *tp = find_tabpage(tabnr);
+ 
+ 	    if (tp == NULL)	/* done all tab pages */
+ 		break;
+ 
+ 	    if (tabnr > 1 && put_line(fd, "tabnew") == FAIL)
+ 		return FAIL;
+ 	}
+ 
+ 	num_tabs = tabnr - 1;
+ 	if (num_tabs > 1 && (fprintf(fd, "tabnext -%d", num_tabs - 1) < 0
+ 						       || put_eol(fd) == FAIL))
+ 	    return FAIL;
+     }
      for (tabnr = 1; ; ++tabnr)
      {
! 	int	need_tabnext = FALSE;
  	int	cnr = 1;
  
  	if ((ssop_flags & SSOP_TABPAGES))
***************
*** 11215,11221 ****
  		tab_topframe = tp->tp_topframe;
  	    }
  	    if (tabnr > 1)
! 		need_tabnew = TRUE;
  	}
  
  	/*
--- 11242,11248 ----
  		tab_topframe = tp->tp_topframe;
  	    }
  	    if (tabnr > 1)
! 		need_tabnext = TRUE;
  	}
  
  	/*
***************
*** 11233,11243 ****
  #endif
  		    )
  	    {
! 		if (fputs(need_tabnew ? "tabedit " : "edit ", fd) < 0
  			      || ses_fname(fd, wp->w_buffer, &ssop_flags, TRUE)
  								       == FAIL)
  		    return FAIL;
- 		need_tabnew = FALSE;
  		if (!wp->w_arg_idx_invalid)
  		    edited_win = wp;
  		break;
--- 11260,11273 ----
  #endif
  		    )
  	    {
! 		if (need_tabnext && put_line(fd, "tabnext") == FAIL)
! 		    return FAIL;
! 		need_tabnext = FALSE;
! 
! 		if (fputs("edit ", fd) < 0
  			      || ses_fname(fd, wp->w_buffer, &ssop_flags, TRUE)
  								       == FAIL)
  		    return FAIL;
  		if (!wp->w_arg_idx_invalid)
  		    edited_win = wp;
  		break;
***************
*** 11245,11251 ****
  	}
  
  	/* If no file got edited create an empty tab page. */
! 	if (need_tabnew && put_line(fd, "tabnew") == FAIL)
  	    return FAIL;
  
  	/*
--- 11275,11281 ----
  	}
  
  	/* If no file got edited create an empty tab page. */
! 	if (need_tabnext && put_line(fd, "tabnext") == FAIL)
  	    return FAIL;
  
  	/*
***************
*** 11348,11354 ****
      /*
       * Wipe out an empty unnamed buffer we started in.
       */
!     if (put_line(fd, "if exists('s:wipebuf') && s:wipebuf != bufnr('%')")
  								       == FAIL)
  	return FAIL;
      if (put_line(fd, "  silent exe 'bwipe ' . s:wipebuf") == FAIL)
--- 11378,11384 ----
      /*
       * Wipe out an empty unnamed buffer we started in.
       */
!     if (put_line(fd, "if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0")
  								       == FAIL)
  	return FAIL;
      if (put_line(fd, "  silent exe 'bwipe ' . s:wipebuf") == FAIL)
*** ../vim-8.1.0148/src/testdir/test_mksession.vim	2018-06-12 16:49:26.366028607 +0200
--- src/testdir/test_mksession.vim	2018-07-04 22:15:48.099410298 +0200
***************
*** 162,167 ****
--- 162,214 ----
    call delete('Xtest_mks.out')
  endfunc
  
+ func Test_mksession_lcd_multiple_tabs()
+   tabnew
+   tabnew
+   lcd
+   tabfirst
+   lcd
+   mksession! Xtest_mks.out
+   tabonly
+   source Xtest_mks.out
+   call assert_true(haslocaldir(), 'Tab 1 localdir')
+   tabnext 2
+   call assert_true(!haslocaldir(), 'Tab 2 localdir')
+   tabnext 3
+   call assert_true(haslocaldir(), 'Tab 3 localdir')
+   call delete('Xtest_mks.out')
+ endfunc
+ 
+ func Test_mksession_blank_tabs()
+   tabnew
+   tabnew
+   tabnew
+   tabnext 3
+   mksession! Xtest_mks.out
+   tabnew
+   tabnew
+   tabnext 2
+   source Xtest_mks.out
+   call assert_equal(4, tabpagenr('$'), 'session restore should restore number of tabs')
+   call assert_equal(3, tabpagenr(), 'session restore should restore the active tab')
+   call delete('Xtest_mks.out')
+ endfunc
+ 
+ func Test_mksession_blank_windows()
+   split
+   split
+   split
+   3 wincmd w
+   mksession! Xtest_mks.out
+   split
+   split
+   2 wincmd w
+   source Xtest_mks.out
+   call assert_equal(4, winnr('$'), 'session restore should restore number of windows')
+   call assert_equal(3, winnr(), 'session restore should restore the active window')
+   call delete('Xtest_mks.out')
+ endfunc
+ 
  if has('terminal')
  
  func Test_mksession_terminal_shell()
*** ../vim-8.1.0148/src/version.c	2018-07-04 22:12:19.880483379 +0200
--- src/version.c	2018-07-04 22:18:05.734679485 +0200
***************
*** 791,792 ****
--- 791,794 ----
  {   /* Add new patch number below this line */
+ /**/
+     149,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
179. You wonder why your household garbage can doesn't have an
     "empty recycle bin" button.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///