Open lucypero opened 3 years ago
reproduce steps ??
Take this Odin program:
package main
main :: proc()
{
panic("");
}
then run it with AsyncRun
:AsyncRun odin run main.odin
Even though the program just exits normally when you run it on cmd.exe
, AsyncRun gets stuck and you cannot quit the program with AsyncStop
and so you can't run the program again. I have to restart vim every time.
I failed to setup an odin environment. could you provide another example in C or C++ or Python ??
My guess:
Suggest:
for windows, just:
:AsyncRun -mode=external odin run main.odin
@skywind3000
Simply running this program breaks AsyncRun.
int main(){
return -1;
}
cl main.c /nologo
Then on vim:
:AsyncRun main
gets it stuck forever. Only fix is to restart vim. Running the same program on the console is fine.
Is there a way so that AsyncStop actually works?
can't reproduce your error:
Ok, I tested it with vim and it works. Then I tested it with Neovim with the same config and it doesn't. Maybe Neovim is the problem.
sorry, I forgot you are using neovim and I just tested it in vim. Now, It can be reproduced after I switched to neovim:
After some inspection, I found it is neovim's issue on windows, if a process returns a code below zero, neovim's job system will hang there, no further events can be received from job system's callback.
The workaround is very simple, just return something >= 0:
See, successfully exited.
So keep your return code above or equal to zero. OR use a script launch.cmd to start your job:
@echo off
call %*
exit 0
This launch.cmd
will override your program's return code. use it to start your program:
:AsyncRun launch.cmd main
the process exited as expected. a new command modifier may help here:
let g:asyncrun_program = get(g:, 'asyncrun_program', {})
let g:asyncrun_program.fix = { opts -> 'd:\launch.cmd ' . opts.cmd }
Then:
:AsyncRun -program=fix main
When -program=fix
is provided, the command will be modified to a new string:
Unfortunately this bug still exists with the latest release from https://github.com/neovim/neovim . Has anyone opened an issue there or attempted to make a PR for it?
Can this be closed ? after the new commit: https://github.com/skywind3000/asyncrun.vim/commit/a7a83c1ecdcd54636247454694ddd5d9086e3b68
I tested it on the latest version of Async and returning negative numbers no longer hangs the program.
Also, Asyncrun believes the program is still running at some instances, for example when the program panics because of an error. AsyncStop() never works in these instances. It doesn't do anything. So I can't run the program again. I have to restart vim every time this happens.
I use it on Neovim on Windows
Example: https://github.com/skywind3000/asyncrun.vim/issues/204#issuecomment-705730506