Thanks to the new apis in vim 8. I have just released a plugin "asyncrun" to
run a shell command in background and display the output to the quickfix window
This is a better alternative to old "vim-dispatch" plugin by using the
advantage of vim 8.
My friends and I has been using and improving it for months. Usually we start
exploring the error output in quickfix window immediately while the command is
still running. We added a condition on whether invoke ":cbottom" after append a
new line in quickfix window by ":caddexpr":
1. if current cursor in qf window is on the last line before ":caddexpr",
invoke ":cbottom" after ":caddexpr", and scroll the qf window.
2. if current cursor in qf window isn't on the last line, skip ":cbottom" and
call ":caddexpr" to populate qf directly.
The code is like these:
" quickfix window cursor check
if &buftype == 'quickfix'
if line('.') != line('$')
let s:qf_cursor_on_last_line = 0
" check if quickfix window can scroll now
let s:qf_cursor_on_last_line = 1
let l:winnr = winnr()
windo call s:AsyncRun_Job_Cursor()
silent exec ''.l:winnr.'wincmd w'
":cbottom" is only invoked if AsyncRun_Job_CheckScroll returns non-zero.
So, if someone need read the output while executing, they just need to go to
the qf window, and move cursor to the line above, auto scroll will stop, if
they want to continue read the newest output, they just need press 'G' in qf
window, ":cbottom" will continue be invoked and qf window will start scrolling
It works fine and have a very good user experience.
but one downside is lack of performance, especially display some crazy STL
error output to quickfix window, vim alyways get unresponsed while cpu usage
another little downside is calling ":windo" before each ":caddexp" will make
the cursor blink in a strange frequency. (maybe a little bug in vim).
due to this we have to disable these "last line checking" feature by default.
So, can we have a "!" after ":caddexpr" and ":cexpr" ?
If there is a "!" after ":caddexpr" or ":cexpr", they can detect cursor
position of the qf window in current tab-page, and make scroll after append
text if cursor in qf window is on the last line ?
Quickfix is a fundamental module which becomes more useful after introducing
async job system in vim.
It could be much helpful not only for my asyncrun, but a lot of other plugins
who use quickfix window and async jobs together.
require for comments.
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
You received this message because you are subscribed to the Google Groups
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/d/optout.