comparison autoload/gutentags.vim @ 199:f7a417234dea

Simplify call sites for `add_progress`, fix bugs with the progress tracking. - `add_progress` makes paths absolute itself instead of the call sites. - `inprogress` debug function properly prints what's going on. - status line function shows which modules are indexing.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 27 Jul 2017 23:08:18 -0700
parents 2489b4b54d5c
children b50b6d0f82dd
comparison
equal deleted inserted replaced
198:5fb056a9eefb 199:f7a417234dea
309 let s:maybe_in_progress[module] = {} 309 let s:maybe_in_progress[module] = {}
310 endfor 310 endfor
311 311
312 " Make a given file known as being currently generated or updated. 312 " Make a given file known as being currently generated or updated.
313 function! gutentags#add_progress(module, file) abort 313 function! gutentags#add_progress(module, file) abort
314 let s:maybe_in_progress[a:module][a:file] = localtime() 314 let l:abs_file = fnamemodify(a:file, ':p')
315 let s:maybe_in_progress[a:module][l:abs_file] = localtime()
315 endfunction 316 endfunction
316 317
317 " Get how to execute an external command depending on debug settings. 318 " Get how to execute an external command depending on debug settings.
318 function! gutentags#get_execute_cmd() abort 319 function! gutentags#get_execute_cmd() abort
319 if has('win32') 320 if has('win32')
461 echom "" 462 echom ""
462 endfunction 463 endfunction
463 464
464 function! gutentags#inprogress() 465 function! gutentags#inprogress()
465 echom "gutentags: generations in progress:" 466 echom "gutentags: generations in progress:"
466 for mip in keys(s:maybe_in_progress) 467 for mod_name in keys(s:maybe_in_progress)
467 echom mip 468 for mib in keys(s:maybe_in_progress[mod_name])
469 echom mod_name.": ".mib
470 endfor
468 endfor 471 endfor
469 echom "" 472 echom ""
470 endfunction 473 endfunction
471 474
472 " }}} 475 " }}}
503 for module in keys(b:gutentags_files) 506 for module in keys(b:gutentags_files)
504 let l:abs_tag_file = fnamemodify(b:gutentags_files[module], ':p') 507 let l:abs_tag_file = fnamemodify(b:gutentags_files[module], ':p')
505 let l:progress_queue = s:maybe_in_progress[module] 508 let l:progress_queue = s:maybe_in_progress[module]
506 let l:timestamp = get(l:progress_queue, l:abs_tag_file) 509 let l:timestamp = get(l:progress_queue, l:abs_tag_file)
507 if l:timestamp == 0 510 if l:timestamp == 0
508 return '' 511 continue
509 endif 512 endif
510 " It's maybe generating! Check if the lock file is still there... but 513 " It's maybe generating! Check if the lock file is still there... but
511 " don't do it too soon after the script was originally launched, because 514 " don't do it too soon after the script was originally launched, because
512 " there can be a race condition where we get here just before the script 515 " there can be a race condition where we get here just before the script
513 " had a chance to write the lock file. 516 " had a chance to write the lock file.
514 if (localtime() - l:timestamp) > 1 && 517 if (localtime() - l:timestamp) > 1 &&
515 \!filereadable(l:abs_tag_file . '.lock') 518 \!filereadable(l:abs_tag_file . '.lock')
516 call remove(l:progress_queue, l:abs_tag_file) 519 call remove(l:progress_queue, l:abs_tag_file)
517 return '' 520 continue
518 endif 521 endif
519 call add(l:modules_in_progress, module) 522 call add(l:modules_in_progress, module)
520 endfor 523 endfor
524
525 if len(l:modules_in_progress) == 0
526 return ''
527 endif
521 528
522 " It's still there! So probably `ctags` is still running... 529 " It's still there! So probably `ctags` is still running...
523 " (although there's a chance it crashed, or the script had a problem, and 530 " (although there's a chance it crashed, or the script had a problem, and
524 " the lock file has been left behind... we could try and run some 531 " the lock file has been left behind... we could try and run some
525 " additional checks here to see if it's legitimately running, and 532 " additional checks here to see if it's legitimately running, and
526 " otherwise delete the lock file... maybe in the future...) 533 " otherwise delete the lock file... maybe in the future...)
527 if len(g:gutentags_modules) > 1 534 let l:gen_msg .= '['.join(l:modules_in_progress, ',').']'
528 let l:gen_msg .= '['.join(l:modules_in_progress, ',').']'
529 endif
530 return l:gen_msg 535 return l:gen_msg
531 endfunction 536 endfunction
532 537
533 " }}} 538 " }}}
534 539