diff --git a/aider/editor.py b/aider/editor.py index 1ff7aef60..a98781bee 100644 --- a/aider/editor.py +++ b/aider/editor.py @@ -104,18 +104,13 @@ def discover_editor(editor_override=None): default_editor = DEFAULT_EDITOR_OS_X else: default_editor = DEFAULT_EDITOR_NIX + if editor_override: editor = editor_override else: editor = get_environment_editor(default_editor) - try: - if system == "Windows": - return shlex.split(editor, posix=False) - else: - return shlex.split(editor) - except ValueError as e: - raise RuntimeError(f"Invalid editor command format '{editor}': {e}") + return editor def pipe_editor(input_data="", suffix=None, editor=None): """ @@ -133,9 +128,8 @@ def pipe_editor(input_data="", suffix=None, editor=None): :rtype: str """ filepath = write_temp_file(input_data, suffix) - command_parts = discover_editor(editor) - command_parts.append(filepath) - command_str = " ".join(shlex.quote(part) for part in command_parts) + command_str = discover_editor(editor) + command_str += " " + filepath subprocess.call(command_str, shell=True) with open(filepath, "r") as f: diff --git a/tests/basic/test_editor.py b/tests/basic/test_editor.py index 415798da6..0522909f7 100644 --- a/tests/basic/test_editor.py +++ b/tests/basic/test_editor.py @@ -84,10 +84,6 @@ def test_discover_editor_override(): assert discover_editor("code") == "code" assert discover_editor('vim -c "set noswapfile"') == 'vim -c "set noswapfile"' - # Test invalid editor command - with pytest.raises(RuntimeError): - discover_editor('vim "unclosed quote') - def test_pipe_editor_with_fake_editor(): # Create a temporary Python script that logs its arguments