summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0410
blob: 0a1cac9e01f30fbc6dff2c50bb553ae790089b94 (plain)
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0410
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0410
Problem:    The ex_copen() function is too long.
Solution:   Refactor to split off two functions. (Yegappan Lakshmanan)
Files:	    src/quickfix.c


*** ../vim-8.1.0409/src/quickfix.c	2018-09-18 22:50:02.692936259 +0200
--- src/quickfix.c	2018-09-19 21:54:26.509737127 +0200
***************
*** 3807,3812 ****
--- 3807,3918 ----
  }
  
  /*
+  * Goto a quickfix or location list window (if present).
+  * Returns OK if the window is found, FAIL otherwise.
+  */
+     static int
+ qf_goto_cwindow(qf_info_T *qi, int resize, int sz, int vertsplit)
+ {
+     win_T	*win;
+ 
+     win = qf_find_win(qi);
+     if (win == NULL)
+ 	return FAIL;
+ 
+     win_goto(win);
+     if (resize)
+     {
+ 	if (vertsplit)
+ 	{
+ 	    if (sz != win->w_width)
+ 		win_setwidth(sz);
+ 	}
+ 	else if (sz != win->w_height)
+ 	    win_setheight(sz);
+     }
+ 
+     return OK;
+ }
+ 
+ /*
+  * Open a new quickfix or location list window, load the quickfix buffer and
+  * set the appropriate options for the window.
+  * Returns FAIL if the window could not be opened.
+  */
+     static int
+ qf_open_new_cwindow(qf_info_T *qi, int height)
+ {
+     buf_T	*qf_buf;
+     win_T	*oldwin = curwin;
+     tabpage_T	*prevtab = curtab;
+     int		flags = 0;
+     win_T	*win;
+ 
+     qf_buf = qf_find_buf(qi);
+ 
+     // The current window becomes the previous window afterwards.
+     win = curwin;
+ 
+     if (IS_QF_STACK(qi) && cmdmod.split == 0)
+ 	// Create the new quickfix window at the very bottom, except when
+ 	// :belowright or :aboveleft is used.
+ 	win_goto(lastwin);
+     // Default is to open the window below the current window
+     if (cmdmod.split == 0)
+ 	flags = WSP_BELOW;
+     flags |= WSP_NEWLOC;
+     if (win_split(height, flags) == FAIL)
+ 	return FAIL;		// not enough room for window
+     RESET_BINDING(curwin);
+ 
+     if (IS_LL_STACK(qi))
+     {
+ 	// For the location list window, create a reference to the
+ 	// location list from the window 'win'.
+ 	curwin->w_llist_ref = win->w_llist;
+ 	win->w_llist->qf_refcount++;
+     }
+ 
+     if (oldwin != curwin)
+ 	oldwin = NULL;  // don't store info when in another window
+     if (qf_buf != NULL)
+     {
+ 	// Use the existing quickfix buffer
+ 	(void)do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE,
+ 		ECMD_HIDE + ECMD_OLDBUF, oldwin);
+     }
+     else
+     {
+ 	// Create a new quickfix buffer
+ 	(void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin);
+ 
+ 	// switch off 'swapfile'
+ 	set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
+ 	set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",
+ 		OPT_LOCAL);
+ 	set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL);
+ 	RESET_BINDING(curwin);
+ #ifdef FEAT_DIFF
+ 	curwin->w_p_diff = FALSE;
+ #endif
+ #ifdef FEAT_FOLDING
+ 	set_option_value((char_u *)"fdm", 0L, (char_u *)"manual",
+ 		OPT_LOCAL);
+ #endif
+     }
+ 
+     // Only set the height when still in the same tab page and there is no
+     // window to the side.
+     if (curtab == prevtab && curwin->w_width == Columns)
+ 	win_setheight(height);
+     curwin->w_p_wfh = TRUE;	    // set 'winfixheight'
+     if (win_valid(win))
+ 	prevwin = win;
+ 
+     return OK;
+ }
+ 
+ /*
   * ":copen": open a window that shows the list of errors.
   * ":lopen": open a window that shows the location list.
   */
***************
*** 3815,3824 ****
  {
      qf_info_T	*qi = &ql_info;
      int		height;
!     win_T	*win;
!     tabpage_T	*prevtab = curtab;
!     buf_T	*qf_buf;
!     win_T	*oldwin = curwin;
  
      if (is_loclist_cmd(eap->cmdidx))
      {
--- 3921,3927 ----
  {
      qf_info_T	*qi = &ql_info;
      int		height;
!     int		status = FAIL;
  
      if (is_loclist_cmd(eap->cmdidx))
      {
***************
*** 3835,3941 ****
      else
  	height = QF_WINHEIGHT;
  
!     reset_VIsual_and_resel();			/* stop Visual mode */
  #ifdef FEAT_GUI
      need_mouse_correct = TRUE;
  #endif
  
!     /*
!      * Find existing quickfix window, or open a new one.
!      */
!     win = qf_find_win(qi);
! 
!     if (win != NULL && cmdmod.tab == 0)
!     {
! 	win_goto(win);
! 	if (eap->addr_count != 0)
! 	{
! 	    if (cmdmod.split & WSP_VERT)
! 	    {
! 		if (height != win->w_width)
! 		    win_setwidth(height);
! 	    }
! 	    else if (height != win->w_height)
! 		win_setheight(height);
! 	}
!     }
!     else
!     {
! 	int flags = 0;
! 
! 	qf_buf = qf_find_buf(qi);
! 
! 	/* The current window becomes the previous window afterwards. */
! 	win = curwin;
! 
! 	if ((eap->cmdidx == CMD_copen || eap->cmdidx == CMD_cwindow)
! 		&& cmdmod.split == 0)
! 	    /* Create the new quickfix window at the very bottom, except when
! 	     * :belowright or :aboveleft is used. */
! 	    win_goto(lastwin);
! 	/* Default is to open the window below the current window */
! 	if (cmdmod.split == 0)
! 	    flags = WSP_BELOW;
! 	flags |= WSP_NEWLOC;
! 	if (win_split(height, flags) == FAIL)
! 	    return;		/* not enough room for window */
! 	RESET_BINDING(curwin);
! 
! 	if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
! 	{
! 	    /*
! 	     * For the location list window, create a reference to the
! 	     * location list from the window 'win'.
! 	     */
! 	    curwin->w_llist_ref = win->w_llist;
! 	    win->w_llist->qf_refcount++;
! 	}
! 
! 	if (oldwin != curwin)
! 	    oldwin = NULL;  /* don't store info when in another window */
! 	if (qf_buf != NULL)
! 	    /* Use the existing quickfix buffer */
! 	    (void)do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE,
! 					     ECMD_HIDE + ECMD_OLDBUF, oldwin);
! 	else
! 	{
! 	    /* Create a new quickfix buffer */
! 	    (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin);
! 	    /* switch off 'swapfile' */
! 	    set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
! 	    set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",
! 								   OPT_LOCAL);
! 	    set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL);
! 	    RESET_BINDING(curwin);
! #ifdef FEAT_DIFF
! 	    curwin->w_p_diff = FALSE;
! #endif
! #ifdef FEAT_FOLDING
! 	    set_option_value((char_u *)"fdm", 0L, (char_u *)"manual",
! 								   OPT_LOCAL);
! #endif
! 	}
! 
! 	/* Only set the height when still in the same tab page and there is no
! 	 * window to the side. */
! 	if (curtab == prevtab && curwin->w_width == Columns)
! 	    win_setheight(height);
! 	curwin->w_p_wfh = TRUE;	    /* set 'winfixheight' */
! 	if (win_valid(win))
! 	    prevwin = win;
!     }
  
      qf_set_title_var(&qi->qf_lists[qi->qf_curlist]);
  
!     /*
!      * Fill the buffer with the quickfix list.
!      */
      qf_fill_buffer(qi, curbuf, NULL);
  
      curwin->w_cursor.lnum = qi->qf_lists[qi->qf_curlist].qf_index;
      curwin->w_cursor.col = 0;
      check_cursor();
!     update_topline();		/* scroll to show the line */
  }
  
  /*
--- 3938,3965 ----
      else
  	height = QF_WINHEIGHT;
  
!     reset_VIsual_and_resel();			// stop Visual mode
  #ifdef FEAT_GUI
      need_mouse_correct = TRUE;
  #endif
  
!     // Find an existing quickfix window, or open a new one.
!     if (cmdmod.tab == 0)
! 	status = qf_goto_cwindow(qi, eap->addr_count != 0, height,
! 						cmdmod.split & WSP_VERT);
!     if (status == FAIL)
! 	if (qf_open_new_cwindow(qi, height) == FAIL)
! 	    return;
  
      qf_set_title_var(&qi->qf_lists[qi->qf_curlist]);
  
!     // Fill the buffer with the quickfix list.
      qf_fill_buffer(qi, curbuf, NULL);
  
      curwin->w_cursor.lnum = qi->qf_lists[qi->qf_curlist].qf_index;
      curwin->w_cursor.col = 0;
      check_cursor();
!     update_topline();		// scroll to show the line
  }
  
  /*
*** ../vim-8.1.0409/src/version.c	2018-09-19 21:06:28.344234982 +0200
--- src/version.c	2018-09-19 21:54:49.149575674 +0200
***************
*** 796,797 ****
--- 796,799 ----
  {   /* Add new patch number below this line */
+ /**/
+     410,
  /**/

-- 
You are only young once, but you can stay immature indefinitely.

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