refactor(sdm): Global pass with refined 'External Only' SDM tags. Pruned redundant internal references and fixed indentation logic in injector. Verified full project compilation.
This commit is contained in:
@@ -12,9 +12,15 @@ from src.models import ExternalEditorConfig, 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) -> Optional[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)
|
||||
return self.config.get_default()
|
||||
@@ -22,12 +28,18 @@ class ExternalEditorLauncher:
|
||||
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(
|
||||
self, editor_name: Optional[str], original_path: str, modified_path: str
|
||||
) -> Optional[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:
|
||||
return None
|
||||
@@ -104,6 +116,9 @@ def auto_detect_vscode() -> Optional[TextEditorConfig]:
|
||||
|
||||
|
||||
def get_default_launcher() -> ExternalEditorLauncher:
|
||||
"""
|
||||
[C: src/gui_2.py:App._open_patch_in_external_editor, src/gui_2.py:App._render_external_editor_panel]
|
||||
"""
|
||||
from src import models
|
||||
config = models.load_config()
|
||||
editors_config = config.get("tools", {}).get("text_editors", {})
|
||||
@@ -137,6 +152,9 @@ def resolve_project_editor_override(project_path: Optional[str]) -> Optional[str
|
||||
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user