Skip to content

Comments

Quote args containing spaces in ArgsStringOrList#195

Merged
tartarughina merged 2 commits intozed-extensions:mainfrom
tartarughina:main
Feb 21, 2026
Merged

Quote args containing spaces in ArgsStringOrList#195
tartarughina merged 2 commits intozed-extensions:mainfrom
tartarughina:main

Conversation

@tartarughina
Copy link
Collaborator

@tartarughina tartarughina commented Feb 21, 2026

Address #194

When ArgsStringOrList::List elements contain spaces, they are now wrapped in double quotes before joining. This prevents the debugger from splitting paths with spaces into multiple arguments.

Add tests covering list with spaces, list without spaces, single element with spaces, empty list, and single string passthrough.

Tested with debug entry

{
    "label": "Args as list - path with spaces",
    "adapter": "Java",
    "request": "launch",
    "mainClass": "ArgsTest",
    "args": ["C:\\path with spaces\\some file.txt", "arg2"],
    "build": {
      "command": "javac ArgsTest.java",
      "shell": {
        "with_arguments": {
          "program": "/bin/sh",
          "args": ["-c"]
        }
      }
    }
  }

and verified that the provided args with spaces are treated as a single string

image

When ArgsStringOrList::List elements contain spaces, they are now
wrapped in double quotes before joining. This prevents the debugger
from splitting paths with spaces into multiple arguments.

Add tests covering list with spaces, list without spaces, single
element with spaces, empty list, and single string passthrough.
Copy link
Collaborator

@playdohface playdohface left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take my comment as food for thought, but if people actually allow tabs in their file paths they brought it unto themselves imo.

Comment on lines +436 to +438
if s.contains(' ') {
format!("\"{}\"", s)
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My gut says why not just wrap it in quotes unconditionally, but I remember there was a gotcha there. And, I know this would be madness, but can paths technically contain tabs? Like, is the contains(' ') check exhaustive here?

@tartarughina
Copy link
Collaborator Author

I hope to never see a tab in a file path

@tartarughina tartarughina merged commit baf7e38 into zed-extensions:main Feb 21, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants