summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.073
blob: 7d9cedcff7e7eec0dad6f36e40161da85001f676 (plain) (blame)
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
To: vim_dev@googlegroups.com
Subject: Patch 7.4.073
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.4.073
Problem:    Setting undolevels for one buffer changes undo in another.
Solution:   Make 'undolevels' a global-local option. (Christian Brabandt)
Files:      runtime/doc/options.txt, src/buffer.c, src/option.c, src/option.h
            src/structs.h, src/undo.c


*** ../vim-7.4.072/runtime/doc/options.txt	2013-08-10 13:24:57.000000000 +0200
--- runtime/doc/options.txt	2013-11-06 04:18:43.000000000 +0100
***************
*** 7594,7600 ****
  						*'undolevels'* *'ul'*
  'undolevels' 'ul'	number	(default 100, 1000 for Unix, VMS,
  						Win32 and OS/2)
! 			global
  			{not in Vi}
  	Maximum number of changes that can be undone.  Since undo information
  	is kept in memory, higher numbers will cause more memory to be used
--- 7594,7600 ----
  						*'undolevels'* *'ul'*
  'undolevels' 'ul'	number	(default 100, 1000 for Unix, VMS,
  						Win32 and OS/2)
! 			global or local to buffer |global-local|
  			{not in Vi}
  	Maximum number of changes that can be undone.  Since undo information
  	is kept in memory, higher numbers will cause more memory to be used
***************
*** 7605,7612 ****
  <	But you can also get Vi compatibility by including the 'u' flag in
  	'cpoptions', and still be able to use CTRL-R to repeat undo.
  	Also see |undo-two-ways|.
! 	Set to a negative number for no undo at all: >
! 		set ul=-1
  <	This helps when you run out of memory for a single change.
  	Also see |clear-undo|.
  
--- 7605,7613 ----
  <	But you can also get Vi compatibility by including the 'u' flag in
  	'cpoptions', and still be able to use CTRL-R to repeat undo.
  	Also see |undo-two-ways|.
! 	Set to -1 for no undo at all.  You might want to do this only for the
! 	current buffer: >
! 		setlocal ul=-1
  <	This helps when you run out of memory for a single change.
  	Also see |clear-undo|.
  
*** ../vim-7.4.072/src/buffer.c	2013-11-05 17:40:47.000000000 +0100
--- src/buffer.c	2013-11-06 04:25:27.000000000 +0100
***************
*** 1949,1954 ****
--- 1949,1955 ----
      clear_string_option(&buf->b_p_qe);
  #endif
      buf->b_p_ar = -1;
+     buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
  }
  
  /*
*** ../vim-7.4.072/src/option.c	2013-11-05 07:12:59.000000000 +0100
--- src/option.c	2013-11-06 04:34:23.000000000 +0100
***************
*** 234,239 ****
--- 234,240 ----
  #ifdef FEAT_STL_OPT
  # define PV_STL		OPT_BOTH(OPT_WIN(WV_STL))
  #endif
+ #define PV_UL		OPT_BOTH(OPT_BUF(BV_UL))
  #ifdef FEAT_WINDOWS
  # define PV_WFH		OPT_WIN(WV_WFH)
  #endif
***************
*** 2683,2689 ****
  #endif
  			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
      {"undolevels",  "ul",   P_NUM|P_VI_DEF,
! 			    (char_u *)&p_ul, PV_NONE,
  			    {
  #if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
  			    (char_u *)1000L,
--- 2684,2690 ----
  #endif
  			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
      {"undolevels",  "ul",   P_NUM|P_VI_DEF,
! 			    (char_u *)&p_ul, PV_UL,
  			    {
  #if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
  			    (char_u *)1000L,
***************
*** 3313,3318 ****
--- 3314,3320 ----
  
      curbuf->b_p_initialized = TRUE;
      curbuf->b_p_ar = -1;	/* no local 'autoread' value */
+     curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
      check_buf_options(curbuf);
      check_win_options(curwin);
      check_options();
***************
*** 4512,4519 ****
  						((flags & P_VI_DEF) || cp_val)
  						 ?  VI_DEFAULT : VIM_DEFAULT];
  			else if (nextchar == '<')
! 			    value = *(long *)get_varp_scope(&(options[opt_idx]),
! 								  OPT_GLOBAL);
  			else if (((long *)varp == &p_wc
  				    || (long *)varp == &p_wcm)
  				&& (*arg == '<'
--- 4514,4529 ----
  						((flags & P_VI_DEF) || cp_val)
  						 ?  VI_DEFAULT : VIM_DEFAULT];
  			else if (nextchar == '<')
! 			{
! 			    /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
! 			     * use the global value. */
! 			    if ((long *)varp == &curbuf->b_p_ul
! 						    && opt_flags == OPT_LOCAL)
! 				value = NO_LOCAL_UNDOLEVEL;
! 			    else
! 				value = *(long *)get_varp_scope(
! 					     &(options[opt_idx]), OPT_GLOBAL);
! 			}
  			else if (((long *)varp == &p_wc
  				    || (long *)varp == &p_wcm)
  				&& (*arg == '<'
***************
*** 8487,8492 ****
--- 8497,8509 ----
  	u_sync(TRUE);
  	p_ul = value;
      }
+     else if (pp == &curbuf->b_p_ul)
+     {
+ 	/* use the old value, otherwise u_sync() may not work properly */
+ 	curbuf->b_p_ul = old_value;
+ 	u_sync(TRUE);
+ 	curbuf->b_p_ul = value;
+     }
  
  #ifdef FEAT_LINEBREAK
      /* 'numberwidth' must be positive */
***************
*** 9720,9726 ****
  /*
   * Unset local option value, similar to ":set opt<".
   */
- 
      void
  unset_global_local_option(name, from)
      char_u	*name;
--- 9737,9742 ----
***************
*** 9793,9798 ****
--- 9809,9817 ----
  	    clear_string_option(&((win_T *)from)->w_p_stl);
  	    break;
  #endif
+ 	case PV_UL:
+ 	    buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
+ 	    break;
      }
  }
  
***************
*** 9841,9846 ****
--- 9860,9866 ----
  #ifdef FEAT_STL_OPT
  	    case PV_STL:  return (char_u *)&(curwin->w_p_stl);
  #endif
+ 	    case PV_UL:   return (char_u *)&(curbuf->b_p_ul);
  	}
  	return NULL; /* "cannot happen" */
      }
***************
*** 9905,9910 ****
--- 9925,9932 ----
  	case PV_STL:	return *curwin->w_p_stl != NUL
  				    ? (char_u *)&(curwin->w_p_stl) : p->var;
  #endif
+ 	case PV_UL:	return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
+ 				    ? (char_u *)&(curbuf->b_p_ul) : p->var;
  
  #ifdef FEAT_ARABIC
  	case PV_ARAB:	return (char_u *)&(curwin->w_p_arab);
***************
*** 10445,10450 ****
--- 10467,10473 ----
  	    /* options that are normally global but also have a local value
  	     * are not copied, start using the global value */
  	    buf->b_p_ar = -1;
+ 	    buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
  #ifdef FEAT_QUICKFIX
  	    buf->b_p_gp = empty_option;
  	    buf->b_p_mp = empty_option;
*** ../vim-7.4.072/src/option.h	2013-06-26 18:41:39.000000000 +0200
--- src/option.h	2013-11-06 04:17:40.000000000 +0100
***************
*** 1031,1036 ****
--- 1031,1037 ----
      , BV_TW
      , BV_TX
      , BV_UDF
+     , BV_UL
      , BV_WM
      , BV_COUNT	    /* must be the last one */
  };
***************
*** 1109,1111 ****
--- 1110,1115 ----
      , WV_WRAP
      , WV_COUNT	    /* must be the last one */
  };
+ 
+ /* Value for b_p_ul indicating the global value must be used. */
+ #define NO_LOCAL_UNDOLEVEL -123456
*** ../vim-7.4.072/src/structs.h	2013-11-05 07:12:59.000000000 +0100
--- src/structs.h	2013-11-06 04:26:17.000000000 +0100
***************
*** 1627,1632 ****
--- 1627,1633 ----
      char_u	*b_p_dict;	/* 'dictionary' local value */
      char_u	*b_p_tsr;	/* 'thesaurus' local value */
  #endif
+     long	b_p_ul;		/* 'undolevels' local value */
  #ifdef FEAT_PERSISTENT_UNDO
      int		b_p_udf;	/* 'undofile' */
  #endif
*** ../vim-7.4.072/src/undo.c	2013-09-08 15:40:45.000000000 +0200
--- src/undo.c	2013-11-06 04:33:12.000000000 +0100
***************
*** 83,88 ****
--- 83,89 ----
  
  #include "vim.h"
  
+ static long get_undolevel __ARGS((void));
  static void u_unch_branch __ARGS((u_header_T *uhp));
  static u_entry_T *u_get_headentry __ARGS((void));
  static void u_getbot __ARGS((void));
***************
*** 336,341 ****
--- 337,353 ----
  }
  
  /*
+  * Get the undolevle value for the current buffer.
+  */
+     static long
+ get_undolevel()
+ {
+     if (curbuf->b_p_ul == NO_LOCAL_UNDOLEVEL)
+ 	return p_ul;
+     return curbuf->b_p_ul;
+ }
+ 
+ /*
   * Common code for various ways to save text before a change.
   * "top" is the line above the first changed line.
   * "bot" is the line below the last changed line.
***************
*** 419,425 ****
  	curbuf->b_new_change = TRUE;
  #endif
  
! 	if (p_ul >= 0)
  	{
  	    /*
  	     * Make a new header entry.  Do this first so that we don't mess
--- 431,437 ----
  	curbuf->b_new_change = TRUE;
  #endif
  
! 	if (get_undolevel() >= 0)
  	{
  	    /*
  	     * Make a new header entry.  Do this first so that we don't mess
***************
*** 449,455 ****
  	/*
  	 * free headers to keep the size right
  	 */
! 	while (curbuf->b_u_numhead > p_ul && curbuf->b_u_oldhead != NULL)
  	{
  	    u_header_T	    *uhfree = curbuf->b_u_oldhead;
  
--- 461,468 ----
  	/*
  	 * free headers to keep the size right
  	 */
! 	while (curbuf->b_u_numhead > get_undolevel()
! 					       && curbuf->b_u_oldhead != NULL)
  	{
  	    u_header_T	    *uhfree = curbuf->b_u_oldhead;
  
***************
*** 530,536 ****
      }
      else
      {
! 	if (p_ul < 0)		/* no undo at all */
  	    return OK;
  
  	/*
--- 543,549 ----
      }
      else
      {
! 	if (get_undolevel() < 0)	/* no undo at all */
  	    return OK;
  
  	/*
***************
*** 1972,1978 ****
  	{
  	    if (curbuf->b_u_curhead == NULL)		/* first undo */
  		curbuf->b_u_curhead = curbuf->b_u_newhead;
! 	    else if (p_ul > 0)				/* multi level undo */
  		/* get next undo */
  		curbuf->b_u_curhead = curbuf->b_u_curhead->uh_next.ptr;
  	    /* nothing to undo */
--- 1985,1991 ----
  	{
  	    if (curbuf->b_u_curhead == NULL)		/* first undo */
  		curbuf->b_u_curhead = curbuf->b_u_newhead;
! 	    else if (get_undolevel() > 0)		/* multi level undo */
  		/* get next undo */
  		curbuf->b_u_curhead = curbuf->b_u_curhead->uh_next.ptr;
  	    /* nothing to undo */
***************
*** 1993,1999 ****
  	}
  	else
  	{
! 	    if (curbuf->b_u_curhead == NULL || p_ul <= 0)
  	    {
  		beep_flush();	/* nothing to redo */
  		if (count == startcount - 1)
--- 2006,2012 ----
  	}
  	else
  	{
! 	    if (curbuf->b_u_curhead == NULL || get_undolevel() <= 0)
  	    {
  		beep_flush();	/* nothing to redo */
  		if (count == startcount - 1)
***************
*** 2751,2757 ****
      if (im_is_preediting())
  	return;		    /* XIM is busy, don't break an undo sequence */
  #endif
!     if (p_ul < 0)
  	curbuf->b_u_synced = TRUE;  /* no entries, nothing to do */
      else
      {
--- 2764,2770 ----
      if (im_is_preediting())
  	return;		    /* XIM is busy, don't break an undo sequence */
  #endif
!     if (get_undolevel() < 0)
  	curbuf->b_u_synced = TRUE;  /* no entries, nothing to do */
      else
      {
***************
*** 2911,2917 ****
      }
      if (!curbuf->b_u_synced)
  	return;		    /* already unsynced */
!     if (p_ul < 0)
  	return;		    /* no entries, nothing to do */
      else
      {
--- 2924,2930 ----
      }
      if (!curbuf->b_u_synced)
  	return;		    /* already unsynced */
!     if (get_undolevel() < 0)
  	return;		    /* no entries, nothing to do */
      else
      {
*** ../vim-7.4.072/src/version.c	2013-11-06 04:04:29.000000000 +0100
--- src/version.c	2013-11-06 05:21:43.000000000 +0100
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     73,
  /**/

-- 
Living on Earth includes an annual free trip around the Sun.

 /// 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    ///