Private
Public Access
0
0

cleaning cruft part 2

This commit is contained in:
2026-07-05 14:08:03 -04:00
parent 508baa69b6
commit 06898ca5a6
20 changed files with 74 additions and 469 deletions
+2 -18
View File
@@ -68,30 +68,18 @@ EMPTY_TEXT_EDITOR_CONFIG: TextEditorConfig = TextEditorConfig()
class ExternalEditorLauncher:
def __init__(self, config: ExternalEditorConfig):
"""
[C: src/mcp_client.py:_DDGParser.__init__, src/mcp_client.py:_TextExtractor.__init__]
"""
self.config = config
def get_editor(self, editor_name: Optional[str] = None) -> TextEditorConfig:
"""
[C: tests/test_external_editor.py:TestExternalEditorLauncher.test_get_editor_by_name, tests/test_external_editor.py:TestExternalEditorLauncher.test_get_editor_returns_default, tests/test_external_editor.py:TestExternalEditorLauncher.test_get_editor_unknown_name]
"""
if editor_name:
return self.config.editors.get(editor_name) or EMPTY_TEXT_EDITOR_CONFIG
return self.config.get_default()
def build_diff_command(self, editor: TextEditorConfig, original_path: str, modified_path: str) -> List[str]:
"""
[C: tests/test_external_editor.py:TestExternalEditorLauncher.test_build_diff_command, tests/test_external_editor_gui.py:test_verify_command_format, tests/test_external_editor_gui.py:test_verify_vscode_command_format]
"""
cmd = [editor.path] + editor.diff_args + [original_path, modified_path]
return cmd
def launch_diff_result(self, editor_name: Optional[str], original_path: str, modified_path: str) -> Result[subprocess.Popen]:
"""
[C: src/gui_2.py:App._open_patch_in_external_editor, tests/test_external_editor.py:TestExternalEditorLauncher.test_launch_diff_file_not_found, tests/test_external_editor.py:TestExternalEditorLauncher.test_launch_diff_missing_editor, tests/test_external_editor.py:TestExternalEditorLauncher.test_launch_diff_success]
"""
editor = self.get_editor(editor_name)
if not editor.name or not editor.path:
return Result(data=None, errors=[ErrorInfo(kind=ErrorKind.NOT_FOUND, message=f"No editor configured: {editor_name}", source="external_editor.launch_diff_result")])
@@ -118,8 +106,8 @@ def _find_vscode_in_registry() -> Result[Optional[str]]:
for key in reg_keys:
try:
result = subprocess.run(
["powershell", "-Command", f"Get-ItemProperty -Path '{key}' -ErrorAction SilentlyContinue | Where-Object {{ $_.DisplayName -like '*Visual Studio Code*' }} | Select-Object -ExpandProperty InstallLocation"],
capture_output=True, text=True, timeout=5
["powershell", "-Command", f"Get-ItemProperty -Path '{key}' -ErrorAction SilentlyContinue | Where-Object {{ $_.DisplayName -like '*Visual Studio Code*' }} | Select-Object -ExpandProperty InstallLocation"],
capture_output=True, text=True, timeout=5
)
for line in result.stdout.strip().split('\n'):
line = line.strip()
@@ -171,7 +159,6 @@ def get_default_launcher(config: Optional[Dict[str, Any]] = None) -> ExternalEdi
AppController). Direct file I/O (the legacy public functions on src.models) is an
architectural smell (bypasses the controller state owner) and is
forbidden by scripts/audit_no_models_config_io.py.
[C: src/gui_2.py:App._open_patch_in_external_editor, src/gui_2.py:App._render_external_editor_panel]
"""
editors_config = config.get("tools", {}).get("text_editors", {}) if config else {}
default_editor = config.get("tools", {}).get("default_editor", {}).get("default_editor") if config else None
@@ -193,9 +180,6 @@ def get_default_launcher(config: Optional[Dict[str, Any]] = None) -> ExternalEdi
def create_temp_modified_file(content: str) -> str:
"""
[C: src/gui_2.py:App._open_patch_in_external_editor, tests/test_external_editor.py:TestHelperFunctions.test_create_temp_modified_file]
"""
with tempfile.NamedTemporaryFile(mode="w", suffix="_modified", delete=False, encoding="utf-8") as f:
f.write(content)
return f.name