From 2cec16af0edc4724b1f85a38872df4b9077b2bfd Mon Sep 17 00:00:00 2001 From: Miguel Date: Mon, 23 Jun 2025 15:29:22 +0200 Subject: [PATCH] =?UTF-8?q?Se=20implement=C3=B3=20una=20nueva=20funci?= =?UTF-8?q?=C3=B3n=20para=20buscar=20archivos=20de=20workspace=20espec?= =?UTF-8?q?=C3=ADficos=20en=20un=20directorio,=20mejorando=20la=20integrac?= =?UTF-8?q?i=C3=B3n=20con=20editores=20como=20VSCode=20y=20Cursor.=20Adem?= =?UTF-8?q?=C3=A1s,=20se=20actualizaron=20las=20configuraciones=20del=20ar?= =?UTF-8?q?chivo=20de=20workspace=20para=20incluir=20asociaciones=20de=20a?= =?UTF-8?q?rchivos=20y=20recomendaciones=20de=20extensiones,=20optimizando?= =?UTF-8?q?=20la=20experiencia=20del=20usuario=20al=20trabajar=20con=20pro?= =?UTF-8?q?yectos=20de=20Python.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 54 +++++++++++++++++-- .../XML Parser to SCL.code-workspace | 16 +++++- 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 5b2cf86..dc862a9 100644 --- a/app.py +++ b/app.py @@ -10,7 +10,8 @@ from datetime import datetime import time # Added for shutdown delay import sys # Added for platform detection import subprocess # Add this to the imports at the top -import shutil # For shutil.whichimport os +import shutil # For shutil.which +import glob # For finding workspace files # --- Imports for System Tray Icon --- import threading @@ -1211,7 +1212,43 @@ def get_python_markdown_content(project_id, relative_path): # === FIN PYTHON LAUNCHER APIs === -# --- Helper function to find VS Code --- +# --- Helper functions --- +def find_workspace_file(directory, editor): + """ + Busca archivos de workspace específicos en un directorio. + + Args: + directory (str): Directorio donde buscar + editor (str): Editor ('vscode' o 'cursor') + + Returns: + str: Ruta del archivo de workspace encontrado, o None si no hay + """ + if not os.path.isdir(directory): + return None + + # Definir extensiones de archivo según el editor + if editor == 'vscode': + extensions = ['.code-workspace'] + elif editor == 'cursor': + # Cursor puede usar tanto .cursor-workspace como .code-workspace + extensions = ['.cursor-workspace', '.code-workspace'] + else: + return None + + # Buscar archivos con las extensiones apropiadas + for ext in extensions: + pattern = os.path.join(directory, f"*{ext}") + workspace_files = glob.glob(pattern) + + if workspace_files: + # Si hay múltiples, tomar el primero (o se podría implementar lógica más sofisticada) + workspace_file = workspace_files[0] + print(f"Found {editor} workspace: {workspace_file}") + return workspace_file + + return None + def find_vscode_executable(): """Intenta encontrar el ejecutable de VS Code en ubicaciones comunes y en el PATH.""" # Comprobar la variable de entorno VSCODE_PATH primero (si la defines) @@ -1355,9 +1392,18 @@ def open_group_in_editor(editor, group_system, group_id): print(f"Launching {editor_name} from: {editor_path}") print(f"Opening directory: {script_group_path}") - # Para Visual Studio 2022 y proyectos C#, intentar abrir archivo .sln específico + # Buscar archivos de workspace específicos o archivos de solución target_to_open = script_group_path - if editor == 'vs2022' and group_system == 'csharp': + + # Para VSCode y Cursor, buscar archivos de workspace + if editor in ['vscode', 'cursor']: + workspace_file = find_workspace_file(script_group_path, editor) + if workspace_file: + target_to_open = workspace_file + print(f"Found {editor} workspace file: {workspace_file}") + + # Para Visual Studio 2022 y proyectos C#, intentar abrir archivo .sln específico + elif editor == 'vs2022' and group_system == 'csharp': solution_file = csharp_launcher_manager.find_solution_file(group_id) if solution_file: target_to_open = solution_file diff --git a/backend/script_groups/XML Parser to SCL/XML Parser to SCL.code-workspace b/backend/script_groups/XML Parser to SCL/XML Parser to SCL.code-workspace index d8a6611..9419df3 100644 --- a/backend/script_groups/XML Parser to SCL/XML Parser to SCL.code-workspace +++ b/backend/script_groups/XML Parser to SCL/XML Parser to SCL.code-workspace @@ -1,11 +1,25 @@ { "folders": [ { + "name": "XML Parser to SCL", "path": "." }, { "path": "C:/Trabajo/SIDEL/13 - E5.007560 - Modifica O&U - SAE235/Reporte/ExportTia" } ], - "settings": {} + "settings": { + "python.defaultInterpreterPath": "python", + "files.associations": { + "*.xml": "xml", + "*.scl": "structured-text" + } + }, + "extensions": { + "recommendations": [ + "ms-python.python", + "ms-python.flake8", + "ms-python.black-formatter" + ] + } } \ No newline at end of file