summaryrefslogtreecommitdiffstats
path: root/source/ap/vim/patches/7.3.480
blob: 6d1e21dee9a95ab7a92cc5d49ec1260094f116a2 (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
To: vim_dev@googlegroups.com
Subject: Patch 7.3.480
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.3.480
Problem:    When using ":qa" and there is a changed buffer picking the buffer
	    to jump to is not very good.
Solution:   Consider current and other tab pages. (Hirohito Higashi)
Files:	    src/ex_cmds2.c


*** ../vim-7.3.479/src/ex_cmds2.c	2012-02-22 18:29:29.000000000 +0100
--- src/ex_cmds2.c	2012-03-23 17:01:31.000000000 +0100
***************
*** 1569,1574 ****
--- 1569,1594 ----
  		|| forceit);
  }
  
+ static void add_bufnum __ARGS((int *bufnrs, int *bufnump, int nr));
+ 
+ /*
+  * Add a buffer number to "bufnrs", unless it's already there.
+  */
+     static void
+ add_bufnum(bufnrs, bufnump, nr)
+     int	    *bufnrs;
+     int	    *bufnump;
+     int	    nr;
+ {
+     int i;
+ 
+     for (i = 0; i < *bufnump; ++i)
+ 	if (bufnrs[i] == nr)
+ 	    return;
+     bufnrs[*bufnump] = nr;
+     *bufnump = *bufnump + 1;
+ }
+ 
  /*
   * Return TRUE if any buffer was changed and cannot be abandoned.
   * That changed buffer becomes the current buffer.
***************
*** 1577,1608 ****
  check_changed_any(hidden)
      int		hidden;		/* Only check hidden buffers */
  {
      buf_T	*buf;
      int		save;
  #ifdef FEAT_WINDOWS
      win_T	*wp;
  #endif
  
!     for (;;)
      {
! 	/* check curbuf first: if it was changed we can't abandon it */
! 	if (!hidden && curbufIsChanged())
! 	    buf = curbuf;
! 	else
  	{
! 	    for (buf = firstbuf; buf != NULL; buf = buf->b_next)
! 		if ((!hidden || buf->b_nwindows == 0) && bufIsChanged(buf))
! 		    break;
  	}
- 	if (buf == NULL)    /* No buffers changed */
- 	    return FALSE;
- 
- 	/* Try auto-writing the buffer.  If this fails but the buffer no
- 	 * longer exists it's not changed, that's OK. */
- 	if (check_changed(buf, p_awa, TRUE, FALSE, TRUE) && buf_valid(buf))
- 	    break;	    /* didn't save - still changes */
      }
  
      exiting = FALSE;
  #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
      /*
--- 1597,1660 ----
  check_changed_any(hidden)
      int		hidden;		/* Only check hidden buffers */
  {
+     int		ret = FALSE;
      buf_T	*buf;
      int		save;
+     int		i;
+     int		bufnum = 0;
+     int		bufcount = 0;
+     int		*bufnrs;
  #ifdef FEAT_WINDOWS
+     tabpage_T   *tp;
      win_T	*wp;
  #endif
  
!     for (buf = firstbuf; buf != NULL; buf = buf->b_next)
! 	++bufcount;
! 
!     if (bufcount == 0)
! 	return FALSE;
! 
!     bufnrs = (int *)alloc(sizeof(int) * bufcount);
!     if (bufnrs == NULL)
! 	return FALSE;
! 
!     /* curbuf */
!     bufnrs[bufnum++] = curbuf->b_fnum;
! #ifdef FEAT_WINDOWS
!     /* buf in curtab */
!     FOR_ALL_WINDOWS(wp)
! 	if (wp->w_buffer != curbuf)
! 	    add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
! 
!     /* buf in other tab */
!     for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
! 	if (tp != curtab)
! 	    for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next)
! 		add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
! #endif
!     /* any other buf */
!     for (buf = firstbuf; buf != NULL; buf = buf->b_next)
! 	add_bufnum(bufnrs, &bufnum, buf->b_fnum);
! 
!     for (i = 0; i < bufnum; ++i)
      {
! 	buf = buflist_findnr(bufnrs[i]);
! 	if (buf == NULL)
! 	    continue;
! 	if ((!hidden || buf->b_nwindows == 0) && bufIsChanged(buf))
  	{
! 	    /* Try auto-writing the buffer.  If this fails but the buffer no
! 	    * longer exists it's not changed, that's OK. */
! 	    if (check_changed(buf, p_awa, TRUE, FALSE, TRUE) && buf_valid(buf))
! 		break;	    /* didn't save - still changes */
  	}
      }
  
+     if (i >= bufnum)
+ 	goto theend;
+ 
+     ret = TRUE;
      exiting = FALSE;
  #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
      /*
***************
*** 1635,1658 ****
  #ifdef FEAT_WINDOWS
      /* Try to find a window that contains the buffer. */
      if (buf != curbuf)
! 	for (wp = firstwin; wp != NULL; wp = wp->w_next)
  	    if (wp->w_buffer == buf)
  	    {
! 		win_goto(wp);
  # ifdef FEAT_AUTOCMD
  		/* Paranoia: did autocms wipe out the buffer with changes? */
  		if (!buf_valid(buf))
! 		    return TRUE;
  # endif
! 		break;
  	    }
  #endif
  
      /* Open the changed buffer in the current window. */
      if (buf != curbuf)
  	set_curbuf(buf, DOBUF_GOTO);
  
!     return TRUE;
  }
  
  /*
--- 1687,1715 ----
  #ifdef FEAT_WINDOWS
      /* Try to find a window that contains the buffer. */
      if (buf != curbuf)
! 	FOR_ALL_TAB_WINDOWS(tp, wp)
  	    if (wp->w_buffer == buf)
  	    {
! 		goto_tabpage_win(tp, wp);
  # ifdef FEAT_AUTOCMD
  		/* Paranoia: did autocms wipe out the buffer with changes? */
  		if (!buf_valid(buf))
! 		{
! 		    goto theend;
! 		}
  # endif
! 		goto buf_found;
  	    }
+ buf_found:
  #endif
  
      /* Open the changed buffer in the current window. */
      if (buf != curbuf)
  	set_curbuf(buf, DOBUF_GOTO);
  
! theend:
!     vim_free(bufnrs);
!     return ret;
  }
  
  /*
***************
*** 3274,3280 ****
  	    home_replace(NULL, SCRIPT_ITEM(i).sn_name,
  						    NameBuff, MAXPATHL, TRUE);
  	    smsg((char_u *)"%3d: %s", i, NameBuff);
!         }
  }
  
  # if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
--- 3331,3337 ----
  	    home_replace(NULL, SCRIPT_ITEM(i).sn_name,
  						    NameBuff, MAXPATHL, TRUE);
  	    smsg((char_u *)"%3d: %s", i, NameBuff);
! 	}
  }
  
  # if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
*** ../vim-7.3.479/src/version.c	2012-03-23 16:25:13.000000000 +0100
--- src/version.c	2012-03-23 16:48:06.000000000 +0100
***************
*** 716,717 ****
--- 716,719 ----
  {   /* Add new patch number below this line */
+ /**/
+     480,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
243. You unsuccessfully try to download a pizza from www.dominos.com.

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