File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,7 @@ function M.show()
195195 end )
196196
197197 M .view .render :render_tasks ()
198+ M .view .render :toggle_selection ({ test_id }, state .get_test_by_id (test_id ).checked )
198199
199200 state .write_all ()
200201 end
@@ -232,22 +233,32 @@ function M.show()
232233 end
233234 end
234235
236+ local checked_ids = {}
237+
235238 if all_checked then
236239 state .set_by_key (" tests" , function (value )
237240 for i = 1 , # value do
241+ table.insert (checked_ids , i )
238242 value [i ].checked = false
239243 end
240244
241245 return value
242246 end )
247+
248+ M .view .render :toggle_selection (checked_ids , false )
243249 else
244250 state .set_by_key (" tests" , function (value )
245251 for i = 1 , # value do
246- value [i ].checked = true
252+ if not value [i ].checked then
253+ table.insert (checked_ids , i )
254+ value [i ].checked = true
255+ end
247256 end
248257
249258 return value
250259 end )
260+
261+ M .view .render :toggle_selection (checked_ids , true )
251262 end
252263
253264 M .view .render :render_tasks ()
Original file line number Diff line number Diff line change @@ -263,4 +263,20 @@ function AstRender:executed()
263263 self .render (self .layout .view .pane_config .Actions .buf , lines )
264264end
265265
266+ --- @param ids integer[]
267+ --- @param is_checked boolean
268+ function AstRender :toggle_selection (ids , is_checked )
269+ local text = AstText .new ()
270+
271+ if type (ids ) == " table" then
272+ text :append (is_checked and " SELECT " or " UNSELECT " , " AstTextH1" )
273+
274+ for _ , i in ipairs (ids ) do
275+ text :append (string.format (" #%d" , i ), " AstTextP" )
276+ end
277+ end
278+
279+ self .render (self .layout .view .pane_config .Actions .buf , text )
280+ end
281+
266282return AstRender
You can’t perform that action at this time.
0 commit comments