Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions autoload/denops/cache.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ let s:job = v:null
function! denops#cache#update(...) abort
const l:options = extend(#{ reload: v:false }, a:0 ? a:1 : {})
const l:plugins = denops#_internal#plugin#list()
const l:entryfiles = extend([s:mod], map(copy(l:plugins), { _, v -> v.script }))

let l:args = [g:denops#deno, 'cache']

if l:options.reload
let l:args = add(l:args, '--reload')
echomsg '[denops] Forcibly update cache of the following files.'
else
if !l:options.reload
echomsg '[denops] Update cache of the following files. Call `denops#cache#update(#{reload: v:true})` to forcibly update.'
endif

for l:entryfile in l:entryfiles
for l:entryfile in [s:mod] + map(copy(l:plugins), { _, v -> v.script })
echomsg printf('[denops] %s', l:entryfile)

let l:args = [g:denops#deno, 'cache']
if l:options.reload
let l:args = add(l:args, '--reload')
endif
let l:args = add(l:args, l:entryfile)

let s:job = denops#_internal#job#start(l:args, #{
\ on_stderr: funcref('s:on_stderr'),
\ on_exit: funcref('s:on_exit'),
\ env: #{
\ NO_COLOR: 1,
\ DENO_NO_PROMPT: 1,
\ },
\})
call denops#_internal#wait#for(60 * 1000, { -> s:job is# v:null }, 100)
endfor
let l:args = extend(l:args, l:entryfiles)

let s:job = denops#_internal#job#start(l:args, #{
\ on_stderr: funcref('s:on_stderr'),
\ on_exit: funcref('s:on_exit'),
\ env: #{
\ NO_COLOR: 1,
\ DENO_NO_PROMPT: 1,
\ },
\})
call denops#_internal#wait#for(60 * 1000, { -> s:job is# v:null }, 100)

echomsg '[denops] Deno cache is updated.'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Report failures instead of unconditional success.

End with an error summary when any file fails.

-  echomsg '[denops] Deno cache is updated.'
+  if empty(l:failures)
+    echomsg '[denops] Deno cache is updated.'
+  else
+    echohl WarningMsg
+    echomsg printf('[denops] Deno cache finished with errors: %d failure(s).', len(l:failures))
+    for l:f in l:failures
+      echomsg printf('[denops] failed: %s', l:f)
+    endfor
+    echohl None
+  endif
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echomsg '[denops] Deno cache is updated.'
if empty(l:failures)
echomsg '[denops] Deno cache is updated.'
else
echohl WarningMsg
echomsg printf('[denops] Deno cache finished with errors: %d failure(s).', len(l:failures))
for l:f in l:failures
echomsg printf('[denops] failed: %s', l:f)
endfor
echohl None
endif
🤖 Prompt for AI Agents
In autoload/denops/cache.vim around line 33, the code unconditionally echoes a
success message; change it to collect failures during the caching loop (e.g.,
keep a list or counter of failed files when file operations return error), and
after the loop check that collection: if there are failures echoerr a concise
error summary including the failure count (and optionally the filenames) and
return a non-zero/false result, otherwise echomsg the success message; ensure
any error paths push the failed file info into the collection so the final
summary is accurate.

endfunction

Expand Down
Loading