]> git.pld-linux.org Git - packages/vim.git/blob - 7.3.480
- add patches 7.3.619-743
[packages/vim.git] / 7.3.480
1 To: vim_dev@googlegroups.com
2 Subject: Patch 7.3.480
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.3.480
11 Problem:    When using ":qa" and there is a changed buffer picking the buffer
12             to jump to is not very good.
13 Solution:   Consider current and other tab pages. (Hirohito Higashi)
14 Files:      src/ex_cmds2.c
15
16
17 *** ../vim-7.3.479/src/ex_cmds2.c       2012-02-22 18:29:29.000000000 +0100
18 --- src/ex_cmds2.c      2012-03-23 17:01:31.000000000 +0100
19 ***************
20 *** 1569,1574 ****
21 --- 1569,1594 ----
22                 || forceit);
23   }
24   
25 + static void add_bufnum __ARGS((int *bufnrs, int *bufnump, int nr));
26
27 + /*
28 +  * Add a buffer number to "bufnrs", unless it's already there.
29 +  */
30 +     static void
31 + add_bufnum(bufnrs, bufnump, nr)
32 +     int           *bufnrs;
33 +     int           *bufnump;
34 +     int           nr;
35 + {
36 +     int i;
37
38 +     for (i = 0; i < *bufnump; ++i)
39 +       if (bufnrs[i] == nr)
40 +           return;
41 +     bufnrs[*bufnump] = nr;
42 +     *bufnump = *bufnump + 1;
43 + }
44
45   /*
46    * Return TRUE if any buffer was changed and cannot be abandoned.
47    * That changed buffer becomes the current buffer.
48 ***************
49 *** 1577,1608 ****
50   check_changed_any(hidden)
51       int               hidden;         /* Only check hidden buffers */
52   {
53       buf_T     *buf;
54       int               save;
55   #ifdef FEAT_WINDOWS
56       win_T     *wp;
57   #endif
58   
59 !     for (;;)
60       {
61 !       /* check curbuf first: if it was changed we can't abandon it */
62 !       if (!hidden && curbufIsChanged())
63 !           buf = curbuf;
64 !       else
65         {
66 !           for (buf = firstbuf; buf != NULL; buf = buf->b_next)
67 !               if ((!hidden || buf->b_nwindows == 0) && bufIsChanged(buf))
68 !                   break;
69         }
70 -       if (buf == NULL)    /* No buffers changed */
71 -           return FALSE;
72
73 -       /* Try auto-writing the buffer.  If this fails but the buffer no
74 -        * longer exists it's not changed, that's OK. */
75 -       if (check_changed(buf, p_awa, TRUE, FALSE, TRUE) && buf_valid(buf))
76 -           break;          /* didn't save - still changes */
77       }
78   
79       exiting = FALSE;
80   #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
81       /*
82 --- 1597,1660 ----
83   check_changed_any(hidden)
84       int               hidden;         /* Only check hidden buffers */
85   {
86 +     int               ret = FALSE;
87       buf_T     *buf;
88       int               save;
89 +     int               i;
90 +     int               bufnum = 0;
91 +     int               bufcount = 0;
92 +     int               *bufnrs;
93   #ifdef FEAT_WINDOWS
94 +     tabpage_T   *tp;
95       win_T     *wp;
96   #endif
97   
98 !     for (buf = firstbuf; buf != NULL; buf = buf->b_next)
99 !       ++bufcount;
100
101 !     if (bufcount == 0)
102 !       return FALSE;
103
104 !     bufnrs = (int *)alloc(sizeof(int) * bufcount);
105 !     if (bufnrs == NULL)
106 !       return FALSE;
107
108 !     /* curbuf */
109 !     bufnrs[bufnum++] = curbuf->b_fnum;
110 ! #ifdef FEAT_WINDOWS
111 !     /* buf in curtab */
112 !     FOR_ALL_WINDOWS(wp)
113 !       if (wp->w_buffer != curbuf)
114 !           add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
115
116 !     /* buf in other tab */
117 !     for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
118 !       if (tp != curtab)
119 !           for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next)
120 !               add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
121 ! #endif
122 !     /* any other buf */
123 !     for (buf = firstbuf; buf != NULL; buf = buf->b_next)
124 !       add_bufnum(bufnrs, &bufnum, buf->b_fnum);
125
126 !     for (i = 0; i < bufnum; ++i)
127       {
128 !       buf = buflist_findnr(bufnrs[i]);
129 !       if (buf == NULL)
130 !           continue;
131 !       if ((!hidden || buf->b_nwindows == 0) && bufIsChanged(buf))
132         {
133 !           /* Try auto-writing the buffer.  If this fails but the buffer no
134 !           * longer exists it's not changed, that's OK. */
135 !           if (check_changed(buf, p_awa, TRUE, FALSE, TRUE) && buf_valid(buf))
136 !               break;      /* didn't save - still changes */
137         }
138       }
139   
140 +     if (i >= bufnum)
141 +       goto theend;
142
143 +     ret = TRUE;
144       exiting = FALSE;
145   #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
146       /*
147 ***************
148 *** 1635,1658 ****
149   #ifdef FEAT_WINDOWS
150       /* Try to find a window that contains the buffer. */
151       if (buf != curbuf)
152 !       for (wp = firstwin; wp != NULL; wp = wp->w_next)
153             if (wp->w_buffer == buf)
154             {
155 !               win_goto(wp);
156   # ifdef FEAT_AUTOCMD
157                 /* Paranoia: did autocms wipe out the buffer with changes? */
158                 if (!buf_valid(buf))
159 !                   return TRUE;
160   # endif
161 !               break;
162             }
163   #endif
164   
165       /* Open the changed buffer in the current window. */
166       if (buf != curbuf)
167         set_curbuf(buf, DOBUF_GOTO);
168   
169 !     return TRUE;
170   }
171   
172   /*
173 --- 1687,1715 ----
174   #ifdef FEAT_WINDOWS
175       /* Try to find a window that contains the buffer. */
176       if (buf != curbuf)
177 !       FOR_ALL_TAB_WINDOWS(tp, wp)
178             if (wp->w_buffer == buf)
179             {
180 !               goto_tabpage_win(tp, wp);
181   # ifdef FEAT_AUTOCMD
182                 /* Paranoia: did autocms wipe out the buffer with changes? */
183                 if (!buf_valid(buf))
184 !               {
185 !                   goto theend;
186 !               }
187   # endif
188 !               goto buf_found;
189             }
190 + buf_found:
191   #endif
192   
193       /* Open the changed buffer in the current window. */
194       if (buf != curbuf)
195         set_curbuf(buf, DOBUF_GOTO);
196   
197 ! theend:
198 !     vim_free(bufnrs);
199 !     return ret;
200   }
201   
202   /*
203 ***************
204 *** 3274,3280 ****
205             home_replace(NULL, SCRIPT_ITEM(i).sn_name,
206                                                     NameBuff, MAXPATHL, TRUE);
207             smsg((char_u *)"%3d: %s", i, NameBuff);
208 !         }
209   }
210   
211   # if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
212 --- 3331,3337 ----
213             home_replace(NULL, SCRIPT_ITEM(i).sn_name,
214                                                     NameBuff, MAXPATHL, TRUE);
215             smsg((char_u *)"%3d: %s", i, NameBuff);
216 !       }
217   }
218   
219   # if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
220 *** ../vim-7.3.479/src/version.c        2012-03-23 16:25:13.000000000 +0100
221 --- src/version.c       2012-03-23 16:48:06.000000000 +0100
222 ***************
223 *** 716,717 ****
224 --- 716,719 ----
225   {   /* Add new patch number below this line */
226 + /**/
227 +     480,
228   /**/
229
230 -- 
231 hundred-and-one symptoms of being an internet addict:
232 243. You unsuccessfully try to download a pizza from www.dominos.com.
233
234  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
235 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
236 \\\  an exciting new programming language -- http://www.Zimbu.org        ///
237  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
This page took 0.135346 seconds and 3 git commands to generate.