Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

terminal_view: Use backslash escaping for dropped file paths for mac (#57747)

mertkanakkoc7e0f63412c60
diff --git a/Cargo.lock b/Cargo.lock
index c3ae43b5a9c..2445366c126 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -535,6 +535,7 @@ dependencies = [
"serde_json",
"serde_json_lenient",
"settings",
+ "shlex",
"streaming_diff",
"task",
"telemetry",
@@ -18419,6 +18420,7 @@ dependencies = [
"serde_json",
"settings",
"shellexpand",
+ "shlex",
"task",
"terminal",
"theme",
diff --git a/crates/agent_ui/Cargo.toml b/crates/agent_ui/Cargo.toml
index 8b25804d724..822b91c3cd1 100644
--- a/crates/agent_ui/Cargo.toml
+++ b/crates/agent_ui/Cargo.toml
@@ -143,6 +143,7 @@ remote_server = { workspace = true, features = ["test-support"] }
search = { workspace = true, features = ["test-support"] }
semver.workspace = true
+shlex.workspace = true
reqwest_client.workspace = true
tempfile.workspace = true
vim.workspace = true
diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs
index 7fe2d2c0b9f..88d8a5fd86d 100644
--- a/crates/agent_ui/src/agent_panel.rs
+++ b/crates/agent_ui/src/agent_panel.rs
@@ -9038,7 +9038,7 @@ mod tests {
let mut text = String::new();
for path in paths {
text.push(' ');
- text.push_str(&format!("{path:?}"));
+ text.push_str(&shlex::try_quote(path.to_str().unwrap()).unwrap());
}
text.push(' ');
text
diff --git a/crates/terminal_view/Cargo.toml b/crates/terminal_view/Cargo.toml
index 9da4c5ec6e1..5197dee517a 100644
--- a/crates/terminal_view/Cargo.toml
+++ b/crates/terminal_view/Cargo.toml
@@ -32,13 +32,14 @@ menu.workspace = true
pretty_assertions.workspace = true
project.workspace = true
regex.workspace = true
-task.workspace = true
schemars.workspace = true
+task.workspace = true
serde.workspace = true
serde_json.workspace = true
settings.workspace = true
shellexpand.workspace = true
+shlex.workspace = true
terminal.workspace = true
theme.workspace = true
theme_settings.workspace = true
diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs
index 6511497623a..ea888d564cc 100644
--- a/crates/terminal_view/src/terminal_view.rs
+++ b/crates/terminal_view/src/terminal_view.rs
@@ -959,7 +959,7 @@ impl TerminalView {
pub fn add_paths_to_terminal(&self, paths: &[PathBuf], window: &mut Window, cx: &mut App) {
let mut text = paths
.iter()
- .map(|path| format!(" {path:?}"))
+ .filter_map(|path| Some(format!(" {}", shlex::try_quote(path.to_str()?).ok()?)))
.collect::<String>();
text.push(' ');
window.focus(&self.focus_handle(cx), cx);
@@ -2176,7 +2176,7 @@ mod tests {
let mut text = String::new();
for path in paths {
text.push(' ');
- text.push_str(&format!("{path:?}"));
+ text.push_str(&shlex::try_quote(path.to_str().unwrap()).unwrap());
}
text.push(' ');
text