]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(doc): Improve fuzzy file picker doc
authorMao-Yining <mao.yining@outlook.com>
Sat, 18 Jul 2026 12:48:23 +0000 (12:48 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 18 Jul 2026 12:48:23 +0000 (12:48 +0000)
1. Only reset cache after used.
2. Use `expand('**', 1, 1)` than `globpath('.', '**', 1, 1)`.

| Environment     | expand (s) | globpath (s) | expand faster |
| --------------- | ---------- | ------------ | ------------- |
| WSL (small)     | 0.0491     | 0.0537       | 9.4%          |
| Windows (large) | 1.6606     | 2.3565       | 41.9%         |

3. fnamemodify() is useless here.

closes: #20767

Signed-off-by: Mao-Yining <mao.yining@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/cmdline.txt

index 6427507d7ef9996621e1d439dd3c9d3531cc2d4d..0f1fa50dbdc74ee950548b5070b681e0a59285b5 100644 (file)
@@ -1,4 +1,4 @@
-*cmdline.txt*  For Vim version 9.2.  Last change: 2026 May 20
+*cmdline.txt*  For Vim version 9.2.  Last change: 2026 Jul 18
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -1428,16 +1428,15 @@ For example, you can turn the native |:find| command into a fuzzy, interactive
 file picker: >
 
        set findfunc=Find
+       let s:filescache = []
        func Find(arg, _)
          if empty(s:filescache)
-           let s:filescache = globpath('.', '**', 1, 1)
+           autocmd CmdlineLeave : ++once let s:filescache = []
+           let s:filescache = expand('**', 1, 1)
            call filter(s:filescache, '!isdirectory(v:val)')
-           call map(s:filescache, "fnamemodify(v:val, ':.')")
          endif
-         return a:arg == '' ? s:filescache : matchfuzzy(s:filescache, a:arg)
+         return empty(a:arg) ? s:filescache : matchfuzzy(s:filescache, a:arg)
        endfunc
-       let s:filescache = []
-       autocmd CmdlineEnter : let s:filescache = []
 
 The `:Grep` command searches for lines matching a pattern and updates the
 results dynamically as you type (triggered after two characters; note: needs