-
-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How check if the command succeeded? #339
Comments
For programmatic use, |
Thanks. I get a "status is not available in dictionary" when trying this though |
OK |
Maybe I should be more clear. This is what I am trying function! s:BuildAndDebug()
:Make
if dispatch#request().status
autocmd QuickFixCmdPost make ++once call vimspector#Launch()
endif
endfunction Can you tell me what I am doing wrong? |
|
Right, I could have though of that. I got an output now, but there is nothing like "status". There is "completed" though, but that is always 1, if the build fails or not. This is shown as success or failed though.
|
That's the job that is running. If the job is running, then it hasn't exited, and there won't be a |
Well, the code that produced this output, is this command! Debug call BuildAndDebug()<CR>
function! BuildAndDebug()
:Make!
autocmd QuickFixCmdPost make ++once call RunVimspectorIfBuilt()
endfunction
function! RunVimspectorIfBuilt()
echo dispatch#request()
endfunction I would say this is during the autocommand. If I don't run |
Oh, Dispatch fires the |
If I don't use once, Vimspector will be started every time I build. I did succeed doing this using this CMake plugin , but it doesn't kill backround jobs properly. Would also be nice to have a universal solution for all programming languages. Not so easy apparently. |
If you don't use |
I can still not even get the value for status. I am tired. It is a bit late here. Will try again tomorrow. I still think that it would make things much simpler if this plugin would fire events when the task is successful or not. This could easily be followed by an autocmd. |
Another thing I just noticed is you need to use |
I tried both. There is no status value ever |
augroup my_debug
autocmd!
autocmd QuickFixCmdPost make call RunVimspectorIfBuilt()
augroup END
command! Debug call BuildAndDebug()
function! BuildAndDebug()
let g:debug_pending = 1
Make
endfunction
function! RunVimspectorIfBuilt()
if !exists('g:debug_pending') || !has_key(dispatch#request(), 'status')
return
endif
unlet! g:debug_pending
echomsg 'Exited with status ' . dispatch#request().status
endfunction That'll be $200. |
There is nothing being printed for me. I checked the message history multiple times. |
You copied the full example including the |
Yeah, the whole thing. For me the function always returns because there is no key called status. Weird. Anyway, thanks for trying |
This is the correct way to get the status: let status = +readfile(dispatch#request().file . '.complete', 1)[0] That will fail with ENOENT if the request is running, so change the initial guard to The |
Ah yeah that finally works. Now I can finally rest in peace. I'll recommend you! |
Is there any way to see if the build (or any other command) succeeded? It is not clear to me from the readme. I would like to use
:Make
to build and start debugging afterwards, but only when the build was successful of course.The text was updated successfully, but these errors were encountered: