@@ -25,6 +25,7 @@ class Project:
25
25
displayName : str
26
26
name : str
27
27
path : str
28
+ isDirectory : bool
28
29
tags : list [str ]
29
30
30
31
@@ -241,6 +242,7 @@ def configWidget(self):
241
242
"type" : "label" ,
242
243
"text" : """
243
244
The way VSCode is opened can be overridden through terminal command.
245
+ This only works for projects, or recent directories, not workspaces or recent files.
244
246
Terminal will enter the working directory of the project upon selection, execute the command and then close itself.
245
247
246
248
Usecase with direnv - To load direnv environment before opening VSCode, enter the following custom command: direnv exec . code .
@@ -314,10 +316,12 @@ def handleTriggerQuery(self, query):
314
316
query .add (items )
315
317
316
318
# Creates an item for the query based on the project and plugin settings
317
- def _createItem (self , project : Project , query : Query ) -> StandardItem :
319
+ def _createItem (self , project : Project ) -> StandardItem :
318
320
actions : list [Action ] = []
319
321
320
- if self .terminalCommand != "" :
322
+ # Only add terminal command action if the project is a directory
323
+ # Handling single files or workspaces would likely over-complicate the code and options
324
+ if self .terminalCommand != "" and project .isDirectory :
321
325
actions .append (
322
326
Action (
323
327
id = "open-terminal" ,
@@ -463,13 +467,27 @@ def _process_storage():
463
467
data = json .loads (row [1 ])
464
468
465
469
for entry in data ["entries" ]:
466
- # Make sure the recent entry has a path to a directory
467
- if not "folderUri" in entry :
470
+ isDirectory = False
471
+ isWorkspace = False
472
+
473
+ # Get the full path to the recent entry
474
+ if "folderUri" in entry :
475
+ isDirectory = True
476
+ parsed_uri = urlparse (
477
+ entry ["folderUri" ]
478
+ )
479
+ elif "workspace" in entry :
480
+ isWorkspace = True
481
+ parsed_uri = urlparse (
482
+ entry ["workspace" ]["configPath" ]
483
+ )
484
+ elif "fileUri" in entry :
485
+ parsed_uri = urlparse (
486
+ entry ["fileUri" ]
487
+ )
488
+ else :
468
489
continue
469
490
470
- # Get the full path to the project
471
- parsed_uri = urlparse (entry ["folderUri" ])
472
-
473
491
# Only support file URIs
474
492
if parsed_uri .scheme != "file" :
475
493
continue
@@ -484,10 +502,14 @@ def _process_storage():
484
502
485
503
# Get the name of the project from the path
486
504
displayName = os .path .basename (recentPath )
505
+ if isWorkspace :
506
+ displayName = os .path .basename (
507
+ recentPath ) + " (Workspace)"
487
508
488
509
# Add the project to the config
489
510
newConf .projects .append (Project (
490
511
displayName = displayName ,
512
+ isDirectory = isDirectory ,
491
513
name = displayName ,
492
514
path = recentPath ,
493
515
tags = [],
@@ -551,6 +573,7 @@ def _getProjectManagerConfig(self, path: str) -> CachedConfig:
551
573
552
574
project = Project (
553
575
displayName = p ["name" ],
576
+ isDirectory = True ,
554
577
name = p ["name" ],
555
578
path = rootPath ,
556
579
tags = [],
0 commit comments