skywind3000 / asyncrun.vim

:rocket: Run Async Shell Commands in Vim 8.0 / NeoVim and Output to the Quickfix Window !!
https://www.vim.org/scripts/script.php?script_id=5431
MIT License
1.85k stars 109 forks source link

Question about asyncrun#quickfix_toggle #155

Open neur1n opened 5 years ago

neur1n commented 5 years ago

Thanks for your suggestions, I'm now wrapping asyncrun to run my scripts. And I noticed the asyncrun#quickfix_toggle(size, ...) function in the source code, described as "fast command to toggle quickfix" . And I myself use the following function to toggle quickfix window:

function! foo#qf#Toggle() abort
  if !exists('s:qf_opened')
    let l:winid = win_getid()
    execute 'botright copen'
    call win_gotoid(l:winid)
    let s:qf_opened = 1
    return
  endif

  if s:qf_opened
    execute 'cclose'
    let s:qf_opened = 0
  else
    let l:winid = win_getid()
    execute 'botright copen'
    call win_gotoid(l:winid)
    let s:qf_opened = 1
  endif
endfunction

Thus a friendly question: does your function has better performance with winsaveview/winrestview and without win_gotoid? Thanks.