@@ -91,24 +91,21 @@ M.show = function()
9191 return
9292 end
9393
94- if state .bufnr then
95- local cursor_line = api .nvim_win_get_cursor (state .winnr )[1 ]
96-
97- -- TODO this SHOULD NOT be necessary
98- -- Refactor the `eval` code so I can have a callback with this function
99- -- that triggers only when I'm done evaluating the whole tree
100- views .cleanup_view (# state .watched_expressions == 0 , " No expressions" )
94+ -- Since variables aren't ordered, lines may change unexpectedly
95+ -- To handle that, always clear the storage table
96+ for k , _ in pairs (state .expressions_by_line ) do
97+ state .expressions_by_line [k ] = nil
98+ end
99+ -- Also clear variables for the same reason
100+ for k , _ in pairs (state .variables_by_line ) do
101+ state .variables_by_line [k ] = nil
102+ end
101103
102- -- Since variables aren't ordered, lines may change unexpectedly
103- -- To handle that, always clear the storage table
104- for k , _ in pairs (state .expressions_by_line ) do
105- state .expressions_by_line [k ] = nil
106- end
107- -- Also clear variables for the same reason
108- for k , _ in pairs (state .variables_by_line ) do
109- state .variables_by_line [k ] = nil
110- end
104+ if views .cleanup_view (vim .tbl_isempty (state .watched_expressions ), " No expressions" ) then
105+ return
106+ end
111107
108+ if state .bufnr then
112109 local line = 0
113110
114111 for expr_name , expr in pairs (state .watched_expressions ) do
@@ -142,18 +139,7 @@ M.show = function()
142139 line = show_variables_or_err (line , expr )
143140 end
144141
145- -- Workaround to reduce jankiness when redrawing
146- if line > 0 then
147- local content = {}
148- if cursor_line > line then
149- for i = 1 , cursor_line - line do
150- content [i ] = " "
151- end
152- end
153- api .nvim_buf_set_lines (state .bufnr , line , - 1 , true , content )
154-
155- state .cur_pos [" watches" ] = api .nvim_win_set_cursor (state .winnr , { cursor_line , 1 })
156- end
142+ api .nvim_buf_set_lines (state .bufnr , line , - 1 , true , {})
157143 end
158144end
159145
0 commit comments