@@ -7,7 +7,8 @@ local LiveFilter = {}
7
7
function LiveFilter :new (opts , explorer )
8
8
local o = {
9
9
explorer = explorer ,
10
- config = vim .deepcopy (opts .live_filter ),
10
+ prefix = opts .live_filter .prefix ,
11
+ always_show_folders = opts .live_filter .always_show_folders ,
11
12
filter = nil ,
12
13
}
13
14
setmetatable (o , self )
@@ -57,8 +58,8 @@ local function remove_overlay(self)
57
58
overlay_bufnr = 0
58
59
overlay_winnr = 0
59
60
60
- if self .explorer . live_filter . filter == " " then
61
- self . explorer . live_filter . clear_filter ()
61
+ if self .filter == " " then
62
+ self : clear_filter ()
62
63
end
63
64
end
64
65
@@ -96,7 +97,7 @@ function LiveFilter:apply_filter(node_)
96
97
end
97
98
end
98
99
99
- local has_nodes = nodes and (self .config . always_show_folders or # nodes > filtered_nodes )
100
+ local has_nodes = nodes and (self .always_show_folders or # nodes > filtered_nodes )
100
101
local ok , is_match = pcall (matches , self , node )
101
102
node .hidden = not (has_nodes or (ok and is_match ))
102
103
end
106
107
107
108
local function record_char (self )
108
109
vim .schedule (function ()
109
- self .explorer . live_filter . filter = vim .api .nvim_buf_get_lines (overlay_bufnr , 0 , - 1 , false )[1 ]
110
- self . explorer . live_filter . apply_filter ()
110
+ self .filter = vim .api .nvim_buf_get_lines (overlay_bufnr , 0 , - 1 , false )[1 ]
111
+ self : apply_filter ()
111
112
redraw ()
112
113
end )
113
114
end
@@ -132,7 +133,7 @@ local function calculate_overlay_win_width(self)
132
133
local wininfo = vim .fn .getwininfo (view .get_winnr ())[1 ]
133
134
134
135
if wininfo then
135
- return wininfo .width - wininfo .textoff - # self .explorer . live_filter . prefix
136
+ return wininfo .width - wininfo .textoff - # self .prefix
136
137
end
137
138
138
139
return 20
@@ -153,7 +154,7 @@ local function create_overlay(self)
153
154
col = 1 ,
154
155
row = 0 ,
155
156
relative = " cursor" ,
156
- width = calculate_overlay_win_width (self . explorer ),
157
+ width = calculate_overlay_win_width (self ),
157
158
height = 1 ,
158
159
border = " none" ,
159
160
style = " minimal" ,
@@ -165,9 +166,9 @@ local function create_overlay(self)
165
166
vim .api .nvim_buf_set_option (overlay_bufnr , " modifiable" , true ) --- @diagnostic disable-line : deprecated
166
167
end
167
168
168
- vim .api .nvim_buf_set_lines (overlay_bufnr , 0 , - 1 , false , { self .explorer . live_filter . filter })
169
+ vim .api .nvim_buf_set_lines (overlay_bufnr , 0 , - 1 , false , { self .filter })
169
170
vim .cmd " startinsert"
170
- vim .api .nvim_win_set_cursor (overlay_winnr , { 1 , # self .explorer . live_filter . filter + 1 })
171
+ vim .api .nvim_win_set_cursor (overlay_winnr , { 1 , # self .filter + 1 })
171
172
end
172
173
173
174
function LiveFilter :start_filtering ()
0 commit comments