-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one minor nit 👍
helix-term/src/commands.rs
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i pushed a commit that inlines it, and updated the commit message
22ab25d
to
eec7847
Compare
eec7847
to
ad70ffc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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