1
1
-- TODO
2
2
-- getting the node list should apply the filter first (for get_node_at_cursor for instance)
3
3
-- custom configuration
4
- -- placement bug with window (see todo/fixme)
5
4
-- documentation
6
5
-- more advanced matching algorithm
7
6
-- asynchronous node discovery when folders are not yet loaded: (might involve performance issues -> max depth search could fix that)
@@ -36,6 +35,11 @@ function M.remove_overlay()
36
35
a .nvim_win_close (overlay_winnr , { force = true })
37
36
overlay_bufnr = nil
38
37
overlay_winnr = nil
38
+
39
+ if M .filter == " " then
40
+ M .filter = nil
41
+ redraw ()
42
+ end
39
43
end
40
44
41
45
local function record_char ()
@@ -61,16 +65,13 @@ local function configure_buffer_overloay()
61
65
a .nvim_buf_set_keymap (overlay_bufnr , " i" , " <C-c>" , " <cmd>lua require'nvim-tree.live-filter'.cancel_filter()<cr>" , {})
62
66
end
63
67
64
- -- TODO/FIXME: find why it doesn't properly place the column when the screen is split...
65
- local function create_overlay (row , col )
68
+ local function create_overlay ()
66
69
configure_buffer_overloay ()
67
70
overlay_winnr = a .nvim_open_win (overlay_bufnr , true , {
68
- col = col + 2 ,
69
- row = row ,
70
- relative = " win" ,
71
- anchor = " NW" ,
72
- win = view .get_winnr (),
73
- width = 100 ,
71
+ col = 2 ,
72
+ row = 0 ,
73
+ relative = " cursor" ,
74
+ width = a .nvim_win_get_width (view .get_winnr ()) - # M .prefix - 2 ,
74
75
height = 1 ,
75
76
border = " none" ,
76
77
style = " minimal" ,
@@ -86,8 +87,9 @@ function M.start_filtering()
86
87
87
88
redraw ()
88
89
local row = view .hide_root_folder or TreeExplorer .cwd == " /" and 1 or 2
89
- a .nvim_win_set_cursor (view .get_winnr (), { row , # M .prefix })
90
- create_overlay (row - 1 , # M .prefix )
90
+ view .set_cursor { row , # M .prefix }
91
+ -- needs scheduling to let the cursor move before initializing the window
92
+ vim .schedule (create_overlay )
91
93
end
92
94
93
95
local function matches (node , filter )
0 commit comments