Skip to content

Commit da4b1d4

Browse files
Merge pull request #4 from abummoja/main
fixed ```find_vscode()``` error
2 parents 104683c + 85056fd commit da4b1d4

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

app/explorer.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,28 @@
33
import winreg
44

55

6+
def find_vscode():
7+
# Check common install paths to find where vsc is installed
8+
possible_paths = [
9+
os.path.join(os.getenv('LOCALAPPDATA'), 'Programs', 'Microsoft VS Code', 'Code.exe'), # User Installer
10+
os.path.join(os.getenv('ProgramFiles'), 'Microsoft VS Code', 'Code.exe'), # System Installer
11+
os.path.join(os.getenv('ProgramFiles(x86)'), 'Microsoft VS Code', 'Code.exe'), # 32-bit System Installer
12+
]
13+
14+
for path in possible_paths:
15+
if os.path.exists(path):
16+
return path
17+
18+
# If not found, check registry
19+
try:
20+
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
21+
r"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Code.exe")
22+
vscode_path, _ = winreg.QueryValueEx(key, "")
23+
return vscode_path
24+
except FileNotFoundError:
25+
return None
26+
27+
628
class Explorer:
729
"""
830
A class for navigating and interacting with folders in the file system.
@@ -91,7 +113,7 @@ def next():
91113
if selected_folder is not None:
92114
Explorer.change_directory(selected_folder, folders)
93115

94-
def find_vscode():
116+
"""def find_vscode():
95117
# Check common install paths to find where vsc is installed
96118
possible_paths = [
97119
os.path.join(os.getenv('LOCALAPPDATA'), 'Programs', 'Microsoft VS Code', 'Code.exe'), # User Installer
@@ -111,6 +133,7 @@ def find_vscode():
111133
return vscode_path
112134
except FileNotFoundError:
113135
return None
136+
"""
114137

115138
def vscode():
116139
import subprocess, os

0 commit comments

Comments
 (0)