@@ -365,10 +365,10 @@ endfunction
365
365
366
366
function ! run#RunListToggle () abort
367
367
if run#is_qf_open ()
368
- cclose
368
+ silent call run#closelist ()
369
369
else
370
370
call run#update_run_jobs ()
371
- silent copen
371
+ silent call run#openlist ()
372
372
endif
373
373
endfunction
374
374
@@ -471,13 +471,13 @@ function! run#RunBrowseLogs(...) abort
471
471
call add (qf_output, qf_item)
472
472
endfor
473
473
474
- silent call setqflist (qf_output)
475
- silent call setqflist ([], ' a' , {' title' : ' RunLogs' })
474
+ silent call run#setlist (qf_output)
475
+ silent call run#setlist ([], ' a' , {' title' : ' RunLogs' })
476
476
let limit = min ([limit, len (qf_output)])
477
477
let msg = ' Showing the last ' . limit . ' saved logs.'
478
478
call run#print_formatted (' Normal' , msg)
479
479
if ! run#is_qf_open ()
480
- silent copen
480
+ silent call run#openlist ()
481
481
endif
482
482
endfunction
483
483
@@ -493,16 +493,60 @@ function! run#RunDeleteLogs() abort
493
493
endif
494
494
call system (' rm ' . g: rundir . ' /*.log' )
495
495
496
- let qf_title = get (getqflist ({' title' : 1 }), ' title' )
496
+ let qf_title = get (run#getlist ({' title' : 1 }), ' title' )
497
497
if run#is_qf_open () && qf_title == # ' RunLogs'
498
- silent call setqflist ([])
499
- silent call setqflist ([], ' a' , {' title' : ' RunLogs' })
498
+ silent call run#setlist ([])
499
+ silent call run#setlist ([], ' a' , {' title' : ' RunLogs' })
500
500
endif
501
501
call run#print_formatted (' WarningMsg' , ' Deleted all logs.' )
502
502
endfunction
503
503
504
504
505
505
" utility
506
+ function ! run#setlist (... )
507
+ if g: run_use_loclist
508
+ if a: 0 == # 1
509
+ call setloclist (0 , a: 1 )
510
+ elseif a: 0 == # 2
511
+ call setloclist (0 , a: 1 , a: 2 )
512
+ elseif a: 0 == # 3
513
+ call setloclist (0 , a: 1 , a: 2 , a: 3 )
514
+ endif
515
+ else
516
+ if a: 0 == # 1
517
+ call setqflist (a: 1 )
518
+ elseif a: 0 == # 2
519
+ call setqflist (a: 1 , a: 2 )
520
+ elseif a: 0 == # 3
521
+ call setqflist (a: 1 , a: 2 , a: 3 )
522
+ endif
523
+ endif
524
+ endfunction
525
+
526
+ function ! run#getlist (arg)
527
+ if g: run_use_loclist
528
+ call getloclist (a: arg )
529
+ else
530
+ call getqflist (a: arg )
531
+ endif
532
+ endfunction
533
+
534
+ function ! run#openlist ()
535
+ if g: run_use_loclist
536
+ lopen
537
+ else
538
+ copen
539
+ endif
540
+ endfunction
541
+
542
+ function ! run#closelist ()
543
+ if g: run_use_loclist
544
+ lclose
545
+ else
546
+ cclose
547
+ endif
548
+ endfunction
549
+
506
550
function ! run#cmd_input_open_editor (editor_lines, timestamp, ... )
507
551
let options = get (a: , 1 , {})
508
552
let is_send = get (options , ' is_send' )
@@ -582,8 +626,8 @@ function! run#update_run_jobs()
582
626
call extend (s: run_jobs [val[' timestamp' ]], { ' status' : status })
583
627
endfor
584
628
585
- silent call setqflist (qf_output)
586
- silent call setqflist ([], ' a' , {' title' : ' RunList' })
629
+ silent call run#setlist (qf_output)
630
+ silent call run#setlist ([], ' a' , {' title' : ' RunList' })
587
631
endfunction
588
632
589
633
function ! run#alert_and_update (content, ... )
@@ -594,7 +638,7 @@ function! run#alert_and_update(content, ...)
594
638
595
639
call run#update_run_jobs ()
596
640
if (! g: run_quiet_default || run#is_qf_open ()) && ! get (options , ' quiet' )
597
- silent copen
641
+ silent call run#openlist ()
598
642
endif
599
643
let msg_format = get (options , ' msg_format' , ' Normal' )
600
644
call run#print_formatted (msg_format, a: content )
0 commit comments