comparison 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
comparison
equal deleted inserted replaced
20813:a7c491ba7e3f 20814:f23c6543a54d
1945 complete path (which may be too long) is displayed for files which are not 1945 complete path (which may be too long) is displayed for files which are not
1946 under the current directory tree. The file path may need to be simplified to a 1946 under the current directory tree. The file path may need to be simplified to a
1947 common parent directory. 1947 common parent directory.
1948 1948
1949 The displayed text can be customized by setting the 'quickfixtextfunc' option 1949 The displayed text can be customized by setting the 'quickfixtextfunc' option
1950 to a Vim function. This function will be called with a dict argument for 1950 to a Vim function. This function will be called with a dict argument and
1951 every entry in a quickfix or a location list. The dict argument will have the 1951 should return a List of strings to be displayed in the quickfix or location
1952 following fields: 1952 list window. The dict argument will have the following fields:
1953 1953
1954 quickfix set to 1 when called for a quickfix list and 0 when called for 1954 quickfix set to 1 when called for a quickfix list and 0 when called for
1955 a location list. 1955 a location list.
1956 winid for a location list, set to the id of the window with the 1956 winid for a location list, set to the id of the window with the
1957 location list. For a quickfix list, set to 0. Can be used in 1957 location list. For a quickfix list, set to 0. Can be used in
1958 getloclist() to get the location list entry. 1958 getloclist() to get the location list entry.
1959 id quickfix or location list identifier 1959 id quickfix or location list identifier
1960 idx index of the entry in the quickfix or location list 1960 start_idx index of the first entry for which text should be returned
1961 end_idx index of the last entry for which text should be returned
1961 1962
1962 The function should return a single line of text to display in the quickfix 1963 The function should return a single line of text to display in the quickfix
1963 window for the entry identified by idx. The function can obtain information 1964 window for each entry from start_idx to end_idx. The function can obtain
1964 about the current entry using the |getqflist()| function and specifying the 1965 information about the entries using the |getqflist()| function and specifying
1965 quickfix list identifier "id" and the entry index "idx". 1966 the quickfix list identifier "id". For a location list, getloclist() function
1967 can be used with the 'winid' argument.
1966 1968
1967 If a quickfix or location list specific customization is needed, then the 1969 If a quickfix or location list specific customization is needed, then the
1968 'quickfixtextfunc' attribute of the list can be set using the |setqflist()| or 1970 'quickfixtextfunc' attribute of the list can be set using the |setqflist()| or
1969 |setloclist()| function. This overrides the global 'quickfixtextfunc' option. 1971 |setloclist()| function. This overrides the global 'quickfixtextfunc' option.
1970 1972
1975 Example: > 1977 Example: >
1976 " create a quickfix list from v:oldfiles 1978 " create a quickfix list from v:oldfiles
1977 call setqflist([], ' ', {'lines' : v:oldfiles, 'efm' : '%f', 1979 call setqflist([], ' ', {'lines' : v:oldfiles, 'efm' : '%f',
1978 \ 'quickfixtextfunc' : 'QfOldFiles'}) 1980 \ 'quickfixtextfunc' : 'QfOldFiles'})
1979 func QfOldFiles(info) 1981 func QfOldFiles(info)
1980 " get information about the specific quickfix entry 1982 " get information about a range of quickfix entries
1981 let e = getqflist({'id' : a:info.id, 'idx' : a:info.idx, 1983 let items = getqflist({'id' : a:info.id, 'items' : 1}).items
1982 \ 'items' : 1}).items[0] 1984 let l = []
1983 " return the simplified file name 1985 for idx in range(a:info.start_idx - 1, a:info.end_idx - 1)
1984 return fnamemodify(bufname(e.bufnr), ':p:.') 1986 " use the simplified file name
1987 call add(l, fnamemodify(bufname(items[idx].bufnr), ':p:.'))
1988 endfor
1989 return l
1985 endfunc 1990 endfunc
1986 < 1991 <
1987 1992
1988 vim:tw=78:ts=8:noet:ft=help:norl: 1993 vim:tw=78:ts=8:noet:ft=help:norl: