]>
Commit | Line | Data |
---|---|---|
14b40f53 AG |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 6.2.472 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 6.2.472 | |
11 | Problem: When using a FileChangedShell autocommand that changes the current | |
12 | buffer, a buffer exists that can't be wiped out. | |
13 | Also, Vim sometimes crashes when executing an external command | |
14 | that changes the buffer and a FileChangedShell autocommand is | |
15 | used. (Hari Krishna Dara) | |
16 | Users are confused by the warning for a file being changed outside | |
17 | of Vim. | |
18 | Solution: Avoid that the window counter for a buffer is incremented twice. | |
19 | Avoid that buf_check_timestamp() is used recursively. | |
20 | Add a hint to look in the help for more info. | |
21 | Files: src/ex_cmds.c, src/fileio.c | |
22 | ||
23 | ||
24 | *** ../vim-6.2.471/src/ex_cmds.c Mon Apr 5 22:14:07 2004 | |
25 | --- src/ex_cmds.c Tue Apr 13 19:33:07 2004 | |
26 | *************** | |
27 | *** 2711,2718 **** | |
28 | { | |
29 | oldbuf = TRUE; | |
30 | (void)buf_check_timestamp(buf, FALSE); | |
31 | ! /* Check if autocommands made buffer invalid. */ | |
32 | ! if (!buf_valid(buf)) | |
33 | goto theend; | |
34 | #ifdef FEAT_EVAL | |
35 | if (aborting()) /* autocmds may abort script processing */ | |
36 | --- 2711,2723 ---- | |
37 | { | |
38 | oldbuf = TRUE; | |
39 | (void)buf_check_timestamp(buf, FALSE); | |
40 | ! /* Check if autocommands made buffer invalid or changed the current | |
41 | ! * buffer. */ | |
42 | ! if (!buf_valid(buf) | |
43 | ! #ifdef FEAT_AUTOCMD | |
44 | ! || curbuf != old_curbuf | |
45 | ! #endif | |
46 | ! ) | |
47 | goto theend; | |
48 | #ifdef FEAT_EVAL | |
49 | if (aborting()) /* autocmds may abort script processing */ | |
50 | *** ../vim-6.2.471/src/fileio.c Tue Mar 30 22:17:27 2004 | |
51 | --- src/fileio.c Wed Apr 14 22:34:56 2004 | |
52 | *************** | |
53 | *** 1701,1707 **** | |
54 | ++lnum; | |
55 | if (--read_count == 0) | |
56 | { | |
57 | ! error = TRUE; /* break loop */ | |
58 | line_start = ptr; /* nothing left to write */ | |
59 | break; | |
60 | } | |
61 | --- 1701,1707 ---- | |
62 | ++lnum; | |
63 | if (--read_count == 0) | |
64 | { | |
65 | ! error = TRUE; /* break loop */ | |
66 | line_start = ptr; /* nothing left to write */ | |
67 | break; | |
68 | } | |
69 | *************** | |
70 | *** 5503,5508 **** | |
71 | --- 5503,5510 ---- | |
72 | char_u *path; | |
73 | char_u *tbuf; | |
74 | char *mesg = NULL; | |
75 | + char *mesg2; | |
76 | + int helpmesg = FALSE; | |
77 | int reload = FALSE; | |
78 | #if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG) | |
79 | int can_reload = FALSE; | |
80 | *************** | |
81 | *** 5512,5526 **** | |
82 | #ifdef FEAT_GUI | |
83 | int save_mouse_correct = need_mouse_correct; | |
84 | #endif | |
85 | ||
86 | /* If there is no file name, the buffer is not loaded, 'buftype' is | |
87 | ! * set, or we are in the middle of a save: ignore this buffer. */ | |
88 | if (buf->b_ffname == NULL | |
89 | || buf->b_ml.ml_mfp == NULL | |
90 | #if defined(FEAT_QUICKFIX) | |
91 | || *buf->b_p_bt != NUL | |
92 | #endif | |
93 | || buf->b_saving | |
94 | ) | |
95 | return 0; | |
96 | ||
97 | --- 5514,5535 ---- | |
98 | #ifdef FEAT_GUI | |
99 | int save_mouse_correct = need_mouse_correct; | |
100 | #endif | |
101 | + #ifdef FEAT_AUTOCMD | |
102 | + static int busy = FALSE; | |
103 | + #endif | |
104 | ||
105 | /* If there is no file name, the buffer is not loaded, 'buftype' is | |
106 | ! * set, we are in the middle of a save or being called recursively: ignore | |
107 | ! * this buffer. */ | |
108 | if (buf->b_ffname == NULL | |
109 | || buf->b_ml.ml_mfp == NULL | |
110 | #if defined(FEAT_QUICKFIX) | |
111 | || *buf->b_p_bt != NUL | |
112 | #endif | |
113 | || buf->b_saving | |
114 | + #ifdef FEAT_AUTOCMD | |
115 | + || busy | |
116 | + #endif | |
117 | ) | |
118 | return 0; | |
119 | ||
120 | *************** | |
121 | *** 5563,5579 **** | |
122 | else | |
123 | { | |
124 | #ifdef FEAT_AUTOCMD | |
125 | /* | |
126 | * Only give the warning if there are no FileChangedShell | |
127 | * autocommands. | |
128 | */ | |
129 | ! if (apply_autocmds(EVENT_FILECHANGEDSHELL, | |
130 | ! buf->b_fname, buf->b_fname, FALSE, buf)) | |
131 | { | |
132 | if (!buf_valid(buf)) | |
133 | - { | |
134 | EMSG(_("E246: FileChangedShell autocommand deleted buffer")); | |
135 | - } | |
136 | return 2; | |
137 | } | |
138 | else | |
139 | --- 5572,5592 ---- | |
140 | else | |
141 | { | |
142 | #ifdef FEAT_AUTOCMD | |
143 | + int n; | |
144 | + | |
145 | /* | |
146 | * Only give the warning if there are no FileChangedShell | |
147 | * autocommands. | |
148 | + * Avoid being called recursively by setting "busy". | |
149 | */ | |
150 | ! busy = TRUE; | |
151 | ! n = apply_autocmds(EVENT_FILECHANGEDSHELL, | |
152 | ! buf->b_fname, buf->b_fname, FALSE, buf); | |
153 | ! busy = FALSE; | |
154 | ! if (n) | |
155 | { | |
156 | if (!buf_valid(buf)) | |
157 | EMSG(_("E246: FileChangedShell autocommand deleted buffer")); | |
158 | return 2; | |
159 | } | |
160 | else | |
161 | *************** | |
162 | *** 5583,5588 **** | |
163 | --- 5596,5602 ---- | |
164 | mesg = _("E211: Warning: File \"%s\" no longer available"); | |
165 | else | |
166 | { | |
167 | + helpmesg = TRUE; | |
168 | #if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG) | |
169 | can_reload = TRUE; | |
170 | #endif | |
171 | *************** | |
172 | *** 5620,5630 **** | |
173 | path = home_replace_save(buf, buf->b_fname); | |
174 | if (path != NULL) | |
175 | { | |
176 | ! tbuf = alloc((unsigned)(STRLEN(path) + STRLEN(mesg))); | |
177 | sprintf((char *)tbuf, mesg, path); | |
178 | #if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG) | |
179 | if (can_reload) | |
180 | { | |
181 | if (do_dialog(VIM_WARNING, (char_u *)_("Warning"), tbuf, | |
182 | (char_u *)_("&OK\n&Load File"), 1, NULL) == 2) | |
183 | reload = TRUE; | |
184 | --- 5634,5654 ---- | |
185 | path = home_replace_save(buf, buf->b_fname); | |
186 | if (path != NULL) | |
187 | { | |
188 | ! if (helpmesg) | |
189 | ! mesg2 = _("See \":help W11\" for more info."); | |
190 | ! else | |
191 | ! mesg2 = ""; | |
192 | ! tbuf = alloc((unsigned)(STRLEN(path) + STRLEN(mesg) | |
193 | ! + STRLEN(mesg2) + 2)); | |
194 | sprintf((char *)tbuf, mesg, path); | |
195 | #if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG) | |
196 | if (can_reload) | |
197 | { | |
198 | + if (*mesg2 != NUL) | |
199 | + { | |
200 | + STRCAT(tbuf, "\n"); | |
201 | + STRCAT(tbuf, mesg2); | |
202 | + } | |
203 | if (do_dialog(VIM_WARNING, (char_u *)_("Warning"), tbuf, | |
204 | (char_u *)_("&OK\n&Load File"), 1, NULL) == 2) | |
205 | reload = TRUE; | |
206 | *************** | |
207 | *** 5633,5638 **** | |
208 | --- 5657,5667 ---- | |
209 | #endif | |
210 | if (State > NORMAL_BUSY || (State & CMDLINE) || already_warned) | |
211 | { | |
212 | + if (*mesg2 != NUL) | |
213 | + { | |
214 | + STRCAT(tbuf, "; "); | |
215 | + STRCAT(tbuf, mesg2); | |
216 | + } | |
217 | EMSG(tbuf); | |
218 | retval = 2; | |
219 | } | |
220 | *************** | |
221 | *** 5647,5652 **** | |
222 | --- 5676,5684 ---- | |
223 | { | |
224 | msg_start(); | |
225 | msg_puts_attr(tbuf, hl_attr(HLF_E) + MSG_HIST); | |
226 | + if (*mesg2 != NUL) | |
227 | + msg_puts_attr((char_u *)mesg2, | |
228 | + hl_attr(HLF_W) + MSG_HIST); | |
229 | msg_clr_eos(); | |
230 | (void)msg_end(); | |
231 | if (emsg_silent == 0) | |
232 | *** ../vim-6.2.471/src/version.c Wed Apr 14 22:12:42 2004 | |
233 | --- src/version.c Wed Apr 14 22:36:28 2004 | |
234 | *************** | |
235 | *** 639,640 **** | |
236 | --- 639,642 ---- | |
237 | { /* Add new patch number below this line */ | |
238 | + /**/ | |
239 | + 472, | |
240 | /**/ | |
241 | ||
242 | -- | |
243 | ARTHUR: What does it say? | |
244 | BROTHER MAYNARD: It reads ... "Here may be found the last words of Joseph of | |
245 | Aramathea." "He who is valorous and pure of heart may find | |
246 | the Holy Grail in the aaaaarrrrrrggghhh..." | |
247 | ARTHUR: What? | |
248 | BROTHER MAYNARD: "The Aaaaarrrrrrggghhh..." | |
249 | "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD | |
250 | ||
251 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
252 | /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
253 | \\\ Project leader for A-A-P -- http://www.A-A-P.org /// | |
254 | \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html /// |