summaryrefslogtreecommitdiffstats
path: root/source/ap/vim/patches/7.2.241
blob: 42e9ade39eea7d0c103c70bd36fd677abb3186c8 (about) (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
To: vim-dev@vim.org
Subject: Patch 7.2.241
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.2.241
Problem:    When using a combination of ":bufdo" and "doautoall" we may end up
	    in the wrong directory. (Ajit Thakkar)
	    Crash when triggering an autocommand in ":vimgrep".  (Yukihiro
	    Nakadaira)
Solution:   Clear w_localdir and globaldir when using the aucmd_win.
	    Use a separate flag to decide aucmd_win needs to be restored.
Files:	    src/fileio.c, src/globals.h, src/structs.h


*** ../vim-7.2.240/src/fileio.c	2009-07-01 17:11:40.000000000 +0200
--- src/fileio.c	2009-07-22 19:08:55.000000000 +0200
***************
*** 8420,8425 ****
--- 8420,8429 ----
  	if (aucmd_win == NULL)
  	    win = curwin;
      }
+     if (win == NULL && aucmd_win_used)
+ 	/* Strange recursive autocommand, fall back to using the current
+ 	 * window.  Expect a few side effects... */
+ 	win = curwin;
  
      aco->save_curwin = curwin;
      aco->save_curbuf = curbuf;
***************
*** 8428,8433 ****
--- 8432,8438 ----
  	/* There is a window for "buf" in the current tab page, make it the
  	 * curwin.  This is preferred, it has the least side effects (esp. if
  	 * "buf" is curbuf). */
+ 	aco->use_aucmd_win = FALSE;
  	curwin = win;
      }
      else
***************
*** 8436,8444 ****
--- 8441,8460 ----
  	 * effects, insert it in a the current tab page.
  	 * Anything related to a window (e.g., setting folds) may have
  	 * unexpected results. */
+ 	aco->use_aucmd_win = TRUE;
+ 	aucmd_win_used = TRUE;
  	aucmd_win->w_buffer = buf;
  	++buf->b_nwindows;
  	win_init_empty(aucmd_win); /* set cursor and topline to safe values */
+ 	vim_free(aucmd_win->w_localdir);
+ 	aucmd_win->w_localdir = NULL;
+ 
+ 	/* Make sure w_localdir and globaldir are NULL to avoid a chdir() in
+ 	 * win_enter_ext(). */
+ 	aucmd_win->w_localdir = NULL;
+ 	aco->globaldir = globaldir;
+ 	globaldir = NULL;
+ 
  
  #ifdef FEAT_WINDOWS
  	/* Split the current window, put the aucmd_win in the upper half.
***************
*** 8472,8478 ****
      int dummy;
  #endif
  
!     if (aco->new_curwin == aucmd_win)
      {
  	--curbuf->b_nwindows;
  #ifdef FEAT_WINDOWS
--- 8488,8494 ----
      int dummy;
  #endif
  
!     if (aco->use_aucmd_win)
      {
  	--curbuf->b_nwindows;
  #ifdef FEAT_WINDOWS
***************
*** 8499,8504 ****
--- 8515,8521 ----
  	/* Remove the window and frame from the tree of frames. */
  	(void)winframe_remove(curwin, &dummy, NULL);
  	win_remove(curwin, NULL);
+ 	aucmd_win_used = FALSE;
  	last_status(FALSE);	    /* may need to remove last status line */
  	restore_snapshot(SNAP_AUCMD_IDX, FALSE);
  	(void)win_comp_pos();   /* recompute window positions */
***************
*** 8517,8522 ****
--- 8534,8542 ----
  #endif
  	curbuf = curwin->w_buffer;
  
+ 	vim_free(globaldir);
+ 	globaldir = aco->globaldir;
+ 
  	/* the buffer contents may have changed */
  	check_cursor();
  	if (curwin->w_topline > curbuf->b_ml.ml_line_count)
***************
*** 8541,8547 ****
  #endif
  	{
  	    /* Restore the buffer which was previously edited by curwin, if
! 	     * it was chagned, we are still the same window and the buffer is
  	     * valid. */
  	    if (curwin == aco->new_curwin
  		    && curbuf != aco->new_curbuf
--- 8561,8567 ----
  #endif
  	{
  	    /* Restore the buffer which was previously edited by curwin, if
! 	     * it was changed, we are still the same window and the buffer is
  	     * valid. */
  	    if (curwin == aco->new_curwin
  		    && curbuf != aco->new_curbuf
*** ../vim-7.2.240/src/globals.h	2009-06-16 16:01:34.000000000 +0200
--- src/globals.h	2009-07-22 19:50:53.000000000 +0200
***************
*** 541,546 ****
--- 541,547 ----
  
  #ifdef FEAT_AUTOCMD
  EXTERN win_T	*aucmd_win;	/* window used in aucmd_prepbuf() */
+ EXTERN int	aucmd_win_used INIT(= FALSE);	/* aucmd_win is being used */
  #endif
  
  /*
*** ../vim-7.2.240/src/structs.h	2009-07-09 18:24:24.000000000 +0200
--- src/structs.h	2009-07-22 18:58:35.000000000 +0200
***************
*** 2288,2296 ****
--- 2288,2298 ----
  {
      buf_T	*save_curbuf;	/* saved curbuf */
  #ifdef FEAT_AUTOCMD
+     int		use_aucmd_win;	/* using aucmd_win */
      win_T	*save_curwin;	/* saved curwin */
      win_T	*new_curwin;	/* new curwin */
      buf_T	*new_curbuf;	/* new curbuf */
+     char_u	*globaldir;	/* saved value of globaldir */
  #endif
  } aco_save_T;
  
*** ../vim-7.2.240/src/version.c	2009-07-29 11:10:31.000000000 +0200
--- src/version.c	2009-07-29 12:06:31.000000000 +0200
***************
*** 678,679 ****
--- 678,681 ----
  {   /* Add new patch number below this line */
+ /**/
+     241,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
114. You are counting items, you go "0,1,2,3,4,5,6,7,8,9,A,B,C,D...".

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///