feat: clearer Arguments editor with typed-together detection and one-click fix
- Label now explains the model with an example: a flag and its value go
on separate lines. Placeholder shows the common uv pattern.
- split_suspicious_args() flags lines that contain whitespace plus a
dash-prefixed token ('--directory /path') — legit single args with
spaces ('My Documents') are never touched. Quotes are respected.
- The editor shows a warning under the args box with a 'Fix: split onto
separate lines' button; the fix goes through the undo stack.
This commit is contained in:
@@ -172,6 +172,40 @@ def test_kitchen_sink():
|
||||
assert len(notes) >= 4
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Suspicious-args detection (several argv tokens typed on one line)
|
||||
# --------------------------------------------------------------------------- #
|
||||
def test_split_flag_and_value_on_one_line():
|
||||
fixed, notes = c.split_suspicious_args(["--directory /path/to/server", "run", "main.py"])
|
||||
assert fixed == ["--directory", "/path/to/server", "run", "main.py"]
|
||||
assert len(notes) == 1
|
||||
|
||||
|
||||
def test_split_full_option_string():
|
||||
fixed, notes = c.split_suspicious_args(["-y @pkg/server --port 8080"])
|
||||
assert fixed == ["-y", "@pkg/server", "--port", "8080"]
|
||||
assert notes
|
||||
|
||||
|
||||
def test_split_respects_quotes():
|
||||
fixed, _ = c.split_suspicious_args(['--name "My Server"'])
|
||||
assert fixed == ["--name", "My Server"]
|
||||
|
||||
|
||||
def test_split_leaves_legit_spaces_alone():
|
||||
args = ["/Users/me/My Documents", "hello world", "run"]
|
||||
fixed, notes = c.split_suspicious_args(args)
|
||||
assert fixed == args
|
||||
assert notes == []
|
||||
|
||||
|
||||
def test_split_leaves_clean_args_alone():
|
||||
args = ["--directory", "/path/to/server", "run", "main.py"]
|
||||
fixed, notes = c.split_suspicious_args(args)
|
||||
assert fixed == args
|
||||
assert notes == []
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Config-file repair (load-time)
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
Reference in New Issue
Block a user