Run shell commands asynchronously - #6373
Conversation
e073ba8 to
9b5e430
Compare
|
I think the behavior of I general I want to move helix to a point where we never block the editor on IO unless absolutely necessary (pasting from the clipboard, or piping into the editor, in which case there should be a timeout) so this would be a nice enhancement 👍 You can just replace the call to |
9b5e430 to
22ab25d
Compare
|
i changed it so that |
Yes but that's possible but would require larger changes and would probably be a bit tricky to implement. You would need to split It's definitely a nice improvement I have thaught about before but a bit more work. You can decide yourself If you want to do it in this PR or a seperatly. |
|
i think doing it in a separate PR is best. i don't think im familiar with the codebase enough to accomplish that yet. but i'll be giving a try once i find some time |
pascalkuthe
left a comment
There was a problem hiding this comment.
LGTM, just one minor nit 👍
| fn async_shell_impl( | ||
| shell: &[String], | ||
| cmd: &str, | ||
| input: Option<Rope>, | ||
| ) -> impl std::future::Future<Output = anyhow::Result<(Tendril, bool)>> { | ||
| let shell = shell.to_vec(); | ||
| let cmd = cmd.to_string(); | ||
| async move { shell_impl_async(&shell, &cmd, input).await } | ||
| } | ||
|
|
There was a problem hiding this comment.
I don't think we really need a helper for this. I don't foresee this pattern really being used in other commands and it's simple enough to just inline into the callsite
There was a problem hiding this comment.
i pushed a commit that inlines it, and updated the commit message
22ab25d to
eec7847
Compare
eec7847 to
ad70ffc
Compare
pascalkuthe
left a comment
There was a problem hiding this comment.
LGTM now, nice usability improvement 👍
|
I think I have hit an example where async is not doing what I would like: Z = { Z = [":sh kitty @ close-window --match title:^hx- --ignore-no-match", ":wq" ], Q = ":q!" }
|
|
I run into a smiliar issue than @David-Else, i'm trying to do this: [keys.normal.space]
t = [":sh theme-sync", ":config-reload"]The config is reloaded before my command terminates. |
|
Same issue here, anything that does:
Will cause the file to not be reloaded with latest changes (some programs can't be used with A workaround is Why not add a blocking variant for |
|
Perhaps a |
May this be my first contribution then =), I'll open a PR for it |
|
FYI, i found a workaround with the latest version which bring us command expansion: [keys.normal.space]
t = [":echo %sh{theme-sync}", ":config-reload"] |
If the PR gets merged, you should be able to do: [keys.normal.space]
t = [":sh -b theme-sync", ":config-reload"] |
this pr adds a basic implementation of
run-async-shell-command(alias = 'async-sh') which runs the shell command asynchronously while discarding its output. this is helpful when the command can run for a long time and its output doesn't matter (or can be piped to a file if needed), and it may be desirable to do so without blocking the editor