Skip to content

Commit 75c1ee2

Browse files
committed
Add cache for search files
1 parent 0a967f7 commit 75c1ee2

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

autoload/project/search_files.vim

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
let s:search_files_sort_max = 1000
2+
let s:prev_list = []
3+
let s:prev_display = []
4+
let s:prev_input = ''
25

36
function! project#search_files#Run()
47
if !project#ProjectExist()
@@ -23,9 +26,18 @@ function! s:Init(input)
2326
endfunction
2427

2528
function! s:Update(input)
26-
let [list, display] = s:GetSearchFilesResult(a:input)
27-
call project#SetVariable('input', a:input)
28-
call project#SetVariable('list', list)
29+
if !empty(a:input) && (a:input == s:prev_input)
30+
let list = s:prev_list
31+
let display = s:prev_display
32+
else
33+
let [list, display] = s:GetSearchFilesResult(a:input)
34+
let s:prev_list = list
35+
let s:prev_display = display
36+
let s:prev_input = a:input
37+
38+
call project#SetVariable('input', a:input)
39+
call project#SetVariable('list', list)
40+
endif
2941
call project#ShowInListBuffer(display, a:input)
3042
call project#HighlightCurrentLine(len(display))
3143
call project#HighlightInputChars(a:input)

0 commit comments

Comments
 (0)