4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: When using a combination of ":bufdo" and "doautoall" we may end up
12 in the wrong directory. (Ajit Thakkar)
13 Crash when triggering an autocommand in ":vimgrep". (Yukihiro
15 Solution: Clear w_localdir and globaldir when using the aucmd_win.
16 Use a separate flag to decide aucmd_win needs to be restored.
17 Files: src/fileio.c, src/globals.h, src/structs.h
20 *** ../vim-7.2.240/src/fileio.c 2009-07-01 17:11:40.000000000 +0200
21 --- src/fileio.c 2009-07-22 19:08:55.000000000 +0200
25 if (aucmd_win == NULL)
28 + if (win == NULL && aucmd_win_used)
29 + /* Strange recursive autocommand, fall back to using the current
30 + * window. Expect a few side effects... */
33 aco->save_curwin = curwin;
34 aco->save_curbuf = curbuf;
38 /* There is a window for "buf" in the current tab page, make it the
39 * curwin. This is preferred, it has the least side effects (esp. if
40 * "buf" is curbuf). */
41 + aco->use_aucmd_win = FALSE;
48 * effects, insert it in a the current tab page.
49 * Anything related to a window (e.g., setting folds) may have
50 * unexpected results. */
51 + aco->use_aucmd_win = TRUE;
52 + aucmd_win_used = TRUE;
53 aucmd_win->w_buffer = buf;
55 win_init_empty(aucmd_win); /* set cursor and topline to safe values */
56 + vim_free(aucmd_win->w_localdir);
57 + aucmd_win->w_localdir = NULL;
59 + /* Make sure w_localdir and globaldir are NULL to avoid a chdir() in
60 + * win_enter_ext(). */
61 + aucmd_win->w_localdir = NULL;
62 + aco->globaldir = globaldir;
67 /* Split the current window, put the aucmd_win in the upper half.
73 ! if (aco->new_curwin == aucmd_win)
81 ! if (aco->use_aucmd_win)
88 /* Remove the window and frame from the tree of frames. */
89 (void)winframe_remove(curwin, &dummy, NULL);
90 win_remove(curwin, NULL);
91 + aucmd_win_used = FALSE;
92 last_status(FALSE); /* may need to remove last status line */
93 restore_snapshot(SNAP_AUCMD_IDX, FALSE);
94 (void)win_comp_pos(); /* recompute window positions */
99 curbuf = curwin->w_buffer;
101 + vim_free(globaldir);
102 + globaldir = aco->globaldir;
104 /* the buffer contents may have changed */
106 if (curwin->w_topline > curbuf->b_ml.ml_line_count)
111 /* Restore the buffer which was previously edited by curwin, if
112 ! * it was chagned, we are still the same window and the buffer is
114 if (curwin == aco->new_curwin
115 && curbuf != aco->new_curbuf
119 /* Restore the buffer which was previously edited by curwin, if
120 ! * it was changed, we are still the same window and the buffer is
122 if (curwin == aco->new_curwin
123 && curbuf != aco->new_curbuf
124 *** ../vim-7.2.240/src/globals.h 2009-06-16 16:01:34.000000000 +0200
125 --- src/globals.h 2009-07-22 19:50:53.000000000 +0200
131 EXTERN win_T *aucmd_win; /* window used in aucmd_prepbuf() */
132 + EXTERN int aucmd_win_used INIT(= FALSE); /* aucmd_win is being used */
136 *** ../vim-7.2.240/src/structs.h 2009-07-09 18:24:24.000000000 +0200
137 --- src/structs.h 2009-07-22 18:58:35.000000000 +0200
142 buf_T *save_curbuf; /* saved curbuf */
144 + int use_aucmd_win; /* using aucmd_win */
145 win_T *save_curwin; /* saved curwin */
146 win_T *new_curwin; /* new curwin */
147 buf_T *new_curbuf; /* new curbuf */
148 + char_u *globaldir; /* saved value of globaldir */
152 *** ../vim-7.2.240/src/version.c 2009-07-29 11:10:31.000000000 +0200
153 --- src/version.c 2009-07-29 12:06:31.000000000 +0200
157 { /* Add new patch number below this line */
163 hundred-and-one symptoms of being an internet addict:
164 114. You are counting items, you go "0,1,2,3,4,5,6,7,8,9,A,B,C,D...".
166 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
167 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
168 \\\ download, build and distribute -- http://www.A-A-P.org ///
169 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///