Se implementó una nueva función para buscar archivos de workspace específicos en un directorio, mejorando la integración con editores como VSCode y Cursor. Además, se actualizaron las configuraciones del archivo de workspace para incluir asociaciones de archivos y recomendaciones de extensiones, optimizando la experiencia del usuario al trabajar con proyectos de Python.

This commit is contained in:
Miguel 2025-06-23 15:29:22 +02:00
parent df6e40e68d
commit 2cec16af0e
2 changed files with 65 additions and 5 deletions

54
app.py
View File

@ -10,7 +10,8 @@ from datetime import datetime
import time # Added for shutdown delay import time # Added for shutdown delay
import sys # Added for platform detection import sys # Added for platform detection
import subprocess # Add this to the imports at the top 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 --- # --- Imports for System Tray Icon ---
import threading import threading
@ -1211,7 +1212,43 @@ def get_python_markdown_content(project_id, relative_path):
# === FIN PYTHON LAUNCHER APIs === # === 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(): def find_vscode_executable():
"""Intenta encontrar el ejecutable de VS Code en ubicaciones comunes y en el PATH.""" """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) # 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"Launching {editor_name} from: {editor_path}")
print(f"Opening directory: {script_group_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 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) solution_file = csharp_launcher_manager.find_solution_file(group_id)
if solution_file: if solution_file:
target_to_open = solution_file target_to_open = solution_file

View File

@ -1,11 +1,25 @@
{ {
"folders": [ "folders": [
{ {
"name": "XML Parser to SCL",
"path": "." "path": "."
}, },
{ {
"path": "C:/Trabajo/SIDEL/13 - E5.007560 - Modifica O&U - SAE235/Reporte/ExportTia" "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"
]
}
} }