@@ -310,32 +310,33 @@ function M.start(args, verbose, callback, on_error)
310
310
end
311
311
vim .schedule (function ()
312
312
local executables = {}
313
- for value in output :gmatch (' ([^\n ]*)\n ?' ) do
314
- local is_json , artifact = pcall (vim .fn .json_decode , value )
315
- if not is_json then
316
- goto loop_end
317
- end
318
-
319
- -- only process artifact if it's valid json object and it is a compiler artifact
320
- if type (artifact ) ~= ' table' or artifact .reason ~= ' compiler-artifact' then
321
- goto loop_end
322
- end
323
-
324
- local is_binary = vim .list_contains (artifact .target .crate_types , ' bin' )
325
- local is_build_script = vim .list_contains (artifact .target .kind , ' custom-build' )
326
- local is_test = ((artifact .profile .test == true ) and (artifact .executable ~= nil ))
327
- or vim .list_contains (artifact .target .kind , ' test' )
328
- -- only add executable to the list if we want a binary debug and it is a binary
329
- -- or if we want a test debug and it is a test
330
- if
331
- (cargo_args [1 ] == ' build' and is_binary and not is_build_script )
332
- or (cargo_args [1 ] == ' test' and is_test )
333
- then
334
- table.insert (executables , artifact .executable )
335
- end
336
-
337
- :: loop_end::
338
- end
313
+ vim
314
+ .iter (output :gmatch (' ([^\n ]*)\n ?' ))
315
+ --- @param value string
316
+ :map (function (value )
317
+ local is_json , artifact = pcall (vim .fn .json_decode , value )
318
+ return is_json , artifact
319
+ end )
320
+ --- @param is_json boolean
321
+ :filter (function (is_json , artifact )
322
+ -- only process artifact if it's valid json object and it is a compiler artifact
323
+ return is_json and type (artifact ) == ' table' and artifact .reason == ' compiler-artifact'
324
+ end )
325
+ --- @param artifact table
326
+ :each (function (_ , artifact )
327
+ local is_binary = vim .list_contains (artifact .target .crate_types , ' bin' )
328
+ local is_build_script = vim .list_contains (artifact .target .kind , ' custom-build' )
329
+ local is_test = ((artifact .profile .test == true ) and (artifact .executable ~= nil ))
330
+ or vim .list_contains (artifact .target .kind , ' test' )
331
+ -- only add executable to the list if we want a binary debug and it is a binary
332
+ -- or if we want a test debug and it is a test
333
+ if
334
+ (cargo_args [1 ] == ' build' and is_binary and not is_build_script )
335
+ or (cargo_args [1 ] == ' test' and is_test )
336
+ then
337
+ table.insert (executables , artifact .executable )
338
+ end
339
+ end )
339
340
-- only 1 executable is allowed for debugging - error out if zero or many were found
340
341
if # executables <= 0 then
341
342
on_error (' No compilation artifacts found.' )
0 commit comments