@@ -340,31 +340,31 @@ function cmd.inject()
340340 local q = utils .curr_question ()
341341 if not q then return end
342342
343- if vim . api .nvim_buf_is_valid (q .bufnr ) then
343+ if api .nvim_buf_is_valid (q .bufnr ) then
344344 local start_i , end_i = q :range (true )
345+ local not_found = {}
345346
346- if start_i == nil and end_i == nil then
347- log .error (" `@leet start` and `@leet end` not found" )
348- return
349- end
350-
351- if start_i == nil then
352- log .error (" `@leet start` not found" )
347+ if not start_i then
348+ table.insert (not_found , " `@leet start`" )
353349 else
354350 local before = q :inject (true )
355351 if before then
356- vim . api .nvim_buf_set_lines (q .bufnr , 0 , start_i - 1 , false , vim .split (before , " \n " ))
352+ api .nvim_buf_set_lines (q .bufnr , 0 , start_i - 1 , false , vim .split (before , " \n " ))
357353 end
358354 end
359355
360- if end_i == nil then
361- log . error ( " `@leet end` not found " )
356+ if not end_i then
357+ table.insert ( not_found , " `@leet end`" )
362358 else
363359 local after = q :inject (false )
364360 if after then
365- vim . api .nvim_buf_set_lines (q .bufnr , end_i + 1 , - 1 , false , vim .split (after , " \n " ))
361+ api .nvim_buf_set_lines (q .bufnr , end_i + 1 , - 1 , false , vim .split (after , " \n " ))
366362 end
367363 end
364+
365+ if not vim .tbl_isempty (not_found ) then
366+ log .error (table.concat (not_found , " and " ) .. " not found" )
367+ end
368368 end
369369end
370370
0 commit comments