@@ -25,6 +25,7 @@ class Project:
2525 displayName : str
2626 name : str
2727 path : str
28+ isDirectory : bool
2829 tags : list [str ]
2930
3031
@@ -241,6 +242,7 @@ def configWidget(self):
241242 "type" : "label" ,
242243 "text" : """
243244The way VSCode is opened can be overridden through terminal command.
245+ This only works for projects, or recent directories, not workspaces or recent files.
244246Terminal will enter the working directory of the project upon selection, execute the command and then close itself.
245247
246248Usecase 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):
314316 query .add (items )
315317
316318 # 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 :
318320 actions : list [Action ] = []
319321
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 :
321325 actions .append (
322326 Action (
323327 id = "open-terminal" ,
@@ -463,13 +467,27 @@ def _process_storage():
463467 data = json .loads (row [1 ])
464468
465469 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 :
468489 continue
469490
470- # Get the full path to the project
471- parsed_uri = urlparse (entry ["folderUri" ])
472-
473491 # Only support file URIs
474492 if parsed_uri .scheme != "file" :
475493 continue
@@ -484,10 +502,14 @@ def _process_storage():
484502
485503 # Get the name of the project from the path
486504 displayName = os .path .basename (recentPath )
505+ if isWorkspace :
506+ displayName = os .path .basename (
507+ recentPath ) + " (Workspace)"
487508
488509 # Add the project to the config
489510 newConf .projects .append (Project (
490511 displayName = displayName ,
512+ isDirectory = isDirectory ,
491513 name = displayName ,
492514 path = recentPath ,
493515 tags = [],
@@ -551,6 +573,7 @@ def _getProjectManagerConfig(self, path: str) -> CachedConfig:
551573
552574 project = Project (
553575 displayName = p ["name" ],
576+ isDirectory = True ,
554577 name = p ["name" ],
555578 path = rootPath ,
556579 tags = [],
0 commit comments