Properly pass nested script arguments for tasks (#10776)

Closes
https://github.com/zed-industries/zed/discussions/10732#discussion-6524347
introduced by https://github.com/zed-industries/zed/pull/10548 while
keeping both Python and Bash run selection capabilities.

Also replaced redundant `SpawnTask` struct with `SpawnInTerminal` that
has identical fields.

Release Notes:

- Fixed incorrect task escaping of nested script arguments

---------

Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
This commit is contained in:
Kirill Bulatov 2024-04-19 16:24:35 +03:00 committed by GitHub
parent 9247da77a3
commit 13c17267b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 55 additions and 85 deletions

View file

@ -31,8 +31,11 @@ pub struct SpawnInTerminal {
pub label: String,
/// Executable command to spawn.
pub command: String,
/// Arguments to the command.
/// Arguments to the command, potentially unsubstituted,
/// to let the shell that spawns the command to do the substitution, if needed.
pub args: Vec<String>,
/// A human-readable label, containing command and all of its arguments, joined and substituted.
pub command_label: String,
/// Current working directory to spawn the command into.
pub cwd: Option<PathBuf>,
/// Env overrides for the command, will be appended to the terminal's environment from the settings.
@ -76,18 +79,6 @@ impl ResolvedTask {
&self.substituted_variables
}
/// If the resolution produced a task with the command, returns a string, combined from its command and arguments.
pub fn resolved_command(&self) -> Option<String> {
self.resolved.as_ref().map(|resolved| {
let mut command = resolved.command.clone();
for arg in &resolved.args {
command.push(' ');
command.push_str(arg);
}
command
})
}
/// A human-readable label to display in the UI.
pub fn display_label(&self) -> &str {
self.resolved