summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.1015
blob: fee0641758a3e136981839227485094ee71c2f82 (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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
To: vim_dev@googlegroups.com
Subject: Patch 8.1.1015
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.1015
Problem:    Quickfix buffer shows up in list, can't get buffer number.
Solution:   Make the quickfix buffer unlisted when the quickfix window is
            closed.  get the quickfix buffer number with getqflist().
            (Yegappan Lakshmanan, closes #4113)
Files:	    runtime/doc/eval.txt, runtime/doc/quickfix.txt, src/quickfix.c,
            src/testdir/test_quickfix.vim, src/window.c


*** ../vim-8.1.1014/runtime/doc/eval.txt	2019-03-04 13:18:15.977053527 +0100
--- runtime/doc/eval.txt	2019-03-17 16:34:27.019774609 +0100
***************
*** 4931,4940 ****
  		If the optional {what} dictionary argument is supplied, then
  		returns the items listed in {what} as a dictionary. Refer to
  		|getqflist()| for the supported items in {what}.
! 		If {what} contains 'filewinid', then returns the id of the
! 		window used to display files from the location list. This
! 		field is applicable only when called from a location list
! 		window.
  
  getmatches()						*getmatches()*
  		Returns a |List| with all matches previously defined by
--- 4964,4979 ----
  		If the optional {what} dictionary argument is supplied, then
  		returns the items listed in {what} as a dictionary. Refer to
  		|getqflist()| for the supported items in {what}.
! 
! 		In addition to the items supported by |getqflist()| in {what},
! 		the following item is supported by |getloclist()|:
! 
! 			filewinid 	id of the window used to display files
! 					from the location list. This field is
! 					applicable only when called from a
! 					location list window. See
! 					|location-list-file-window| for more
! 					details.
  
  getmatches()						*getmatches()*
  		Returns a |List| with all matches previously defined by
***************
*** 5036,5041 ****
--- 5075,5083 ----
  			nr	get information for this quickfix list; zero
  				means the current quickfix list and "$" means
  				the last quickfix list
+ 			qfbufnr number of the buffer displayed in the quickfix
+ 				window. Returns 0 if the quickfix buffer is
+ 				not present. See |quickfix-buffer|.
  			size	number of entries in the quickfix list
  			title	get the list title |quickfix-title|
  			winid	get the quickfix |window-ID|
***************
*** 5064,5069 ****
--- 5106,5113 ----
  			items	quickfix list entries. If not present, set to
  				an empty list.
  			nr	quickfix list number. If not present, set to 0
+ 			qfbufnr	number of the buffer displayed in the quickfix
+ 				window. If not present, set to 0.
  			size	number of entries in the quickfix list. If not
  				present, set to 0.
  			title	quickfix list title text. If not present, set
*** ../vim-8.1.1014/runtime/doc/quickfix.txt	2019-01-11 14:49:25.380107431 +0100
--- runtime/doc/quickfix.txt	2019-03-17 16:34:27.019774609 +0100
***************
*** 111,124 ****
  :[count]lne[xt][!]	Same as ":cnext", except the location list for the
  			current window is used instead of the quickfix list.
  
! :[count]cN[ext][!]			*:cp* *:cprevious* *:cN* *:cNext*
  :[count]cp[revious][!]	Display the [count] previous error in the list that
  			includes a file name.  If there are no file names at
  			all, go to the [count] previous error.  See |:cc| for
  			[!] and 'switchbuf'.
  
  
! :[count]lN[ext][!]			*:lp* *:lprevious* *:lN* *:lNext*
  :[count]lp[revious][!]	Same as ":cNext" and ":cprevious", except the location
  			list for the current window is used instead of the
  			quickfix list.
--- 111,124 ----
  :[count]lne[xt][!]	Same as ":cnext", except the location list for the
  			current window is used instead of the quickfix list.
  
! :[count]cN[ext][!]		*:cp* *:cprevious*  *:cprev* *:cN* *:cNext*
  :[count]cp[revious][!]	Display the [count] previous error in the list that
  			includes a file name.  If there are no file names at
  			all, go to the [count] previous error.  See |:cc| for
  			[!] and 'switchbuf'.
  
  
! :[count]lN[ext][!]		*:lp* *:lprevious* *:lprev* *:lN* *:lNext*
  :[count]lp[revious][!]	Same as ":cNext" and ":cprevious", except the location
  			list for the current window is used instead of the
  			quickfix list.
***************
*** 367,374 ****
  <
  							*quickfix-index*
  When you jump to a quickfix/location list entry using any of the quickfix
! commands (e.g. |cc|, |cnext|, |cprev|, etc.), that entry becomes the currently
! selected entry. The index of the currently selected entry in a
  quickfix/location list can be obtained using the getqflist()/getloclist()
  functions. Examples: >
  	echo getqflist({'idx' : 0}).idx
--- 367,374 ----
  <
  							*quickfix-index*
  When you jump to a quickfix/location list entry using any of the quickfix
! commands (e.g. |:cc|, |:cnext|, |:cprev|, etc.), that entry becomes the
! currently selected entry. The index of the currently selected entry in a
  quickfix/location list can be obtained using the getqflist()/getloclist()
  functions. Examples: >
  	echo getqflist({'idx' : 0}).idx
***************
*** 496,501 ****
--- 496,502 ----
  			second quickfix window.  If [height] is given the
  			existing window will be resized to it.
  
+ 							*quickfix-buffer*
  			The window will contain a special buffer, with
  			'buftype' equal to "quickfix".  Don't change this!
  			The window will have the w:quickfix_title variable set
***************
*** 504,510 ****
  			status line if the value of 'statusline' is adjusted
  			properly. Whenever this buffer is modified by a
  			quickfix command or function, the |b:changedtick|
! 			variable is incremented.
  
  							*:lop* *:lopen*
  :lop[en] [height]	Open a window to show the location list for the
--- 505,515 ----
  			status line if the value of 'statusline' is adjusted
  			properly. Whenever this buffer is modified by a
  			quickfix command or function, the |b:changedtick|
! 			variable is incremented.  You can get the number of
! 			this buffer using the getqflist() and getloclist()
! 			functions by passing the 'qfbufnr' item. For a
! 			location list, this buffer is wiped out when the
! 			location list is removed.
  
  							*:lop* *:lopen*
  :lop[en] [height]	Open a window to show the location list for the
***************
*** 670,681 ****
--- 675,692 ----
      " get the quickfix list window id
      :echo getqflist({'winid' : 0}).winid
  
+     " get the quickfix list window buffer number
+     :echo getqflist({'qfbufnr' : 0}).qfbufnr
+ 
      " get the context of the current location list
      :echo getloclist(0, {'context' : 0}).context
  
      " get the location list window id of the third window
      :echo getloclist(3, {'winid' : 0}).winid
  
+     " get the location list window buffer number of the third window
+     :echo getloclist(3, {'qfbufnr' : 0}).qfbufnr
+ 
      " get the file window id of a location list window (winnr: 4)
      :echo getloclist(4, {'filewinid' : 0}).filewinid
  <
*** ../vim-8.1.1014/src/quickfix.c	2019-03-13 06:49:20.492351919 +0100
--- src/quickfix.c	2019-03-17 16:34:27.019774609 +0100
***************
*** 5907,5913 ****
      QF_GETLIST_SIZE	= 0x80,
      QF_GETLIST_TICK	= 0x100,
      QF_GETLIST_FILEWINID	= 0x200,
!     QF_GETLIST_ALL	= 0x3FF,
  };
  
  /*
--- 5907,5914 ----
      QF_GETLIST_SIZE	= 0x80,
      QF_GETLIST_TICK	= 0x100,
      QF_GETLIST_FILEWINID	= 0x200,
!     QF_GETLIST_QFBUFNR	= 0x400,
!     QF_GETLIST_ALL	= 0x7FF,
  };
  
  /*
***************
*** 5977,5982 ****
--- 5978,5994 ----
  }
  
  /*
+  * Returns the number of the buffer displayed in the quickfix/location list
+  * window. If there is no buffer associated with the list, then returns 0.
+  */
+     static int
+ qf_getprop_qfbufnr(qf_info_T *qi, dict_T *retdict)
+ {
+     return dict_add_number(retdict, "qfbufnr",
+ 					(qi == NULL) ? 0 : qi->qf_bufnr);
+ }
+ 
+ /*
   * Convert the keys in 'what' to quickfix list property flags.
   */
      static int
***************
*** 6022,6027 ****
--- 6034,6042 ----
      if (loclist && dict_find(what, (char_u *)"filewinid", -1) != NULL)
  	flags |= QF_GETLIST_FILEWINID;
  
+     if (dict_find(what, (char_u *)"qfbufnr", -1) != NULL)
+ 	flags |= QF_GETLIST_QFBUFNR;
+ 
      return flags;
  }
  
***************
*** 6114,6119 ****
--- 6129,6136 ----
  	status = dict_add_number(retdict, "changedtick", 0);
      if ((status == OK) && locstack && (flags & QF_GETLIST_FILEWINID))
  	status = dict_add_number(retdict, "filewinid", 0);
+     if ((status == OK) && (flags & QF_GETLIST_QFBUFNR))
+ 	status = qf_getprop_qfbufnr(qi, retdict);
  
      return status;
  }
***************
*** 6259,6264 ****
--- 6276,6283 ----
  	status = dict_add_number(retdict, "changedtick", qfl->qf_changedtick);
      if ((status == OK) && (wp != NULL) && (flags & QF_GETLIST_FILEWINID))
  	status = qf_getprop_filewinid(wp, qi, retdict);
+     if ((status == OK) && (flags & QF_GETLIST_QFBUFNR))
+ 	status = qf_getprop_qfbufnr(qi, retdict);
  
      return status;
  }
*** ../vim-8.1.1014/src/testdir/test_quickfix.vim	2019-03-02 07:57:12.236395037 +0100
--- src/testdir/test_quickfix.vim	2019-03-17 16:34:27.019774609 +0100
***************
*** 3110,3128 ****
    call assert_equal(0, g:Xgetlist({'changedtick' : 0}).changedtick)
    if a:cchar == 'c'
      call assert_equal({'context' : '', 'id' : 0, 'idx' : 0,
! 		  \ 'items' : [], 'nr' : 0, 'size' : 0,
  		  \ 'title' : '', 'winid' : 0, 'changedtick': 0},
  		  \ g:Xgetlist({'all' : 0}))
    else
      call assert_equal({'context' : '', 'id' : 0, 'idx' : 0,
  		\ 'items' : [], 'nr' : 0, 'size' : 0, 'title' : '',
! 		\ 'winid' : 0, 'changedtick': 0, 'filewinid' : 0},
  		\ g:Xgetlist({'all' : 0}))
    endif
  
    " Quickfix window with empty stack
    silent! Xopen
    let qfwinid = (a:cchar == 'c') ? win_getid() : 0
    call assert_equal(qfwinid, g:Xgetlist({'winid' : 0}).winid)
    Xclose
  
--- 3110,3130 ----
    call assert_equal(0, g:Xgetlist({'changedtick' : 0}).changedtick)
    if a:cchar == 'c'
      call assert_equal({'context' : '', 'id' : 0, 'idx' : 0,
! 		  \ 'items' : [], 'nr' : 0, 'size' : 0, 'qfbufnr' : 0,
  		  \ 'title' : '', 'winid' : 0, 'changedtick': 0},
  		  \ g:Xgetlist({'all' : 0}))
    else
      call assert_equal({'context' : '', 'id' : 0, 'idx' : 0,
  		\ 'items' : [], 'nr' : 0, 'size' : 0, 'title' : '',
! 		\ 'winid' : 0, 'changedtick': 0, 'filewinid' : 0,
! 		\ 'qfbufnr' : 0},
  		\ g:Xgetlist({'all' : 0}))
    endif
  
    " Quickfix window with empty stack
    silent! Xopen
    let qfwinid = (a:cchar == 'c') ? win_getid() : 0
+   let qfbufnr = (a:cchar == 'c') ? bufnr('') : 0
    call assert_equal(qfwinid, g:Xgetlist({'winid' : 0}).winid)
    Xclose
  
***************
*** 3154,3164 ****
    if a:cchar == 'c'
      call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [],
  		\ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0,
  		\ 'changedtick' : 0}, g:Xgetlist({'id' : qfid, 'all' : 0}))
    else
      call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [],
  		\ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0,
! 		\ 'changedtick' : 0, 'filewinid' : 0},
  		\ g:Xgetlist({'id' : qfid, 'all' : 0}))
    endif
  
--- 3156,3167 ----
    if a:cchar == 'c'
      call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [],
  		\ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0,
+ 		\ 'qfbufnr' : qfbufnr,
  		\ 'changedtick' : 0}, g:Xgetlist({'id' : qfid, 'all' : 0}))
    else
      call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [],
  		\ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0,
! 		\ 'changedtick' : 0, 'filewinid' : 0, 'qfbufnr' : 0},
  		\ g:Xgetlist({'id' : qfid, 'all' : 0}))
    endif
  
***************
*** 3175,3185 ****
    if a:cchar == 'c'
      call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [],
  		\ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0,
! 		\ 'changedtick' : 0}, g:Xgetlist({'nr' : 5, 'all' : 0}))
    else
      call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [],
  		\ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0,
! 		\ 'changedtick' : 0, 'filewinid' : 0},
  		\ g:Xgetlist({'nr' : 5, 'all' : 0}))
    endif
  endfunc
--- 3178,3189 ----
    if a:cchar == 'c'
      call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [],
  		\ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0,
! 		\ 'changedtick' : 0, 'qfbufnr' : qfbufnr},
! 		\ g:Xgetlist({'nr' : 5, 'all' : 0}))
    else
      call assert_equal({'context' : '', 'id' : 0, 'idx' : 0, 'items' : [],
  		\ 'nr' : 0, 'size' : 0, 'title' : '', 'winid' : 0,
! 		\ 'changedtick' : 0, 'filewinid' : 0, 'qfbufnr' : 0},
  		\ g:Xgetlist({'nr' : 5, 'all' : 0}))
    endif
  endfunc
***************
*** 3912,3917 ****
--- 3916,3922 ----
    Xclose
    " Even after the quickfix window is closed, the buffer should be loaded
    call assert_true(bufloaded(qfbnum))
+   call assert_true(qfbnum, g:Xgetlist({'qfbufnr' : 0}).qfbufnr)
    Xopen
    " Buffer should be reused when opening the window again
    call assert_equal(qfbnum, bufnr(''))
***************
*** 3930,3936 ****
      close
      " When the location list window is closed, the buffer name should not
      " change to 'Quickfix List'
!     call assert_match(qfbnum . '  h-  "\[Location List]"', execute('ls'))
      call assert_true(bufloaded(qfbnum))
  
      " After deleting a location list buffer using ":bdelete", opening the
--- 3935,3941 ----
      close
      " When the location list window is closed, the buffer name should not
      " change to 'Quickfix List'
!     call assert_match(qfbnum . 'u h-  "\[Location List]"', execute('ls!'))
      call assert_true(bufloaded(qfbnum))
  
      " After deleting a location list buffer using ":bdelete", opening the
***************
*** 3947,3952 ****
--- 3952,3958 ----
      " removed
      call setloclist(0, [], 'f')
      call assert_false(bufexists(qfbnum))
+     call assert_equal(0, getloclist(0, {'qfbufnr' : 0}).qfbufnr)
  
      " When the location list is freed with the location list window open, the
      " location list buffer should not be lost. It should be reused when the
*** ../vim-8.1.1014/src/window.c	2019-03-04 13:18:15.973053562 +0100
--- src/window.c	2019-03-17 16:36:49.002856677 +0100
***************
*** 2382,2399 ****
      }
  
  #ifdef FEAT_GUI
!     /* Avoid trouble with scrollbars that are going to be deleted in
!      * win_free(). */
      if (gui.in_use)
  	out_flush();
  #endif
  
  #ifdef FEAT_SYN_HL
!     /* Free independent synblock before the buffer is freed. */
      if (win->w_buffer != NULL)
  	reset_synblock(win);
  #endif
  
      /*
       * Close the link to the buffer.
       */
--- 2382,2405 ----
      }
  
  #ifdef FEAT_GUI
!     // Avoid trouble with scrollbars that are going to be deleted in
!     // win_free().
      if (gui.in_use)
  	out_flush();
  #endif
  
  #ifdef FEAT_SYN_HL
!     // Free independent synblock before the buffer is freed.
      if (win->w_buffer != NULL)
  	reset_synblock(win);
  #endif
  
+ #ifdef FEAT_QUICKFIX
+     // When the quickfix/location list window is closed, unlist the buffer.
+     if (win->w_buffer != NULL && bt_quickfix(win->w_buffer))
+ 	win->w_buffer->b_p_bl = FALSE;
+ #endif
+ 
      /*
       * Close the link to the buffer.
       */
*** ../vim-8.1.1014/src/version.c	2019-03-17 15:47:22.589492071 +0100
--- src/version.c	2019-03-17 16:33:12.068262826 +0100
***************
*** 781,782 ****
--- 781,784 ----
  {   /* Add new patch number below this line */
+ /**/
+     1015,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
79. All of your most erotic dreams have a scrollbar at the right side.

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