diff runtime/doc/quickfix.txt @ 20814:f23c6543a54d v8.2.0959

patch 8.2.0959: using 'quickfixtextfunc' is a bit slow Commit: https://github.com/vim/vim/commit/00e260bb6cc33ff5dbba15ac87ca7fd465aa49c0 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jun 11 19:35:52 2020 +0200 patch 8.2.0959: using 'quickfixtextfunc' is a bit slow Problem: Using 'quickfixtextfunc' is a bit slow. Solution: Process a list of entries. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/6234)
author Bram Moolenaar <Bram@vim.org>
date Thu, 11 Jun 2020 19:45:03 +0200
parents 68170c89e355
children 2c40e60017a8
line wrap: on
line diff
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -1947,9 +1947,9 @@ under the current directory tree. The fi
 common parent directory.
 
 The displayed text can be customized by setting the 'quickfixtextfunc' option
-to a Vim function.  This function will be called with a dict argument for
-every entry in a quickfix or a location list. The dict argument will have the
-following fields:
+to a Vim function.  This function will be called with a dict argument and
+should return a List of strings to be displayed in the quickfix or location
+list window. The dict argument will have the following fields:
 
     quickfix	set to 1 when called for a quickfix list and 0 when called for
 		a location list.
@@ -1957,12 +1957,14 @@ following fields:
 		location list. For a quickfix list, set to 0. Can be used in
 		getloclist() to get the location list entry.
     id		quickfix or location list identifier
-    idx		index of the entry in the quickfix or location list
+    start_idx	index of the first entry for which text should be returned
+    end_idx	index of the last entry for which text should be returned
 
 The function should return a single line of text to display in the quickfix
-window for the entry identified by idx. The function can obtain information
-about the current entry using the |getqflist()| function and specifying the
-quickfix list identifier "id" and the entry index "idx".
+window for each entry from start_idx to end_idx. The function can obtain
+information about the entries using the |getqflist()| function and specifying
+the quickfix list identifier "id". For a location list, getloclist() function
+can be used with the 'winid' argument.
 
 If a quickfix or location list specific customization is needed, then the
 'quickfixtextfunc' attribute of the list can be set using the |setqflist()| or
@@ -1977,11 +1979,14 @@ Example: >
     call setqflist([], ' ', {'lines' : v:oldfiles, 'efm' : '%f',
 					\ 'quickfixtextfunc' : 'QfOldFiles'})
     func QfOldFiles(info)
-	" get information about the specific quickfix entry
-	let e = getqflist({'id' : a:info.id, 'idx' : a:info.idx,
-						\ 'items' : 1}).items[0]
-	" return the simplified file name
-	return fnamemodify(bufname(e.bufnr), ':p:.')
+	" get information about a range of quickfix entries
+	let items = getqflist({'id' : a:info.id, 'items' : 1}).items
+	let l = []
+	for idx in range(a:info.start_idx - 1, a:info.end_idx - 1)
+	    " use the simplified file name
+	  call add(l, fnamemodify(bufname(items[idx].bufnr), ':p:.'))
+	endfor
+	return l
     endfunc
 <