diff --git a/YarnSpinner.LanguageServer/src/Server/Workspace/Workspace.cs b/YarnSpinner.LanguageServer/src/Server/Workspace/Workspace.cs
index 5a8f3f5e1..0ed7a856e 100644
--- a/YarnSpinner.LanguageServer/src/Server/Workspace/Workspace.cs
+++ b/YarnSpinner.LanguageServer/src/Server/Workspace/Workspace.cs
@@ -31,6 +31,12 @@ public class Workspace : INotificationSender, IActionSource, IConfigurationSourc
public IWindowLanguageServer? Window => LanguageServer?.Window;
+ ///
+ /// Have we shown a warning about the workspace having no root folder?
+ /// (We only want to show it once.)
+ ///
+ private bool hasShownNullRootWarning = false;
+
///
/// Gets the projects that include the file at .
///
@@ -102,7 +108,20 @@ internal void ReloadWorkspace()
var projects = new List();
- if (this.Root != null)
+ if (this.Root == null)
+ {
+ // We don't have a root folder. The language server won't be
+ // able to find any additional resources, so we should warn the
+ // user about this. (This can happen when the user double-clicks
+ // on a file in Unity, which will open the file directly in VS
+ // Code without a root folder.)
+ if (hasShownNullRootWarning == false)
+ {
+ LanguageServer?.Window.ShowWarning($"This window does not have a folder to work in. Yarn Spinner features will not work as expected. [Open your project's folder](command:vscode.openFolder) for full feature support.");
+ hasShownNullRootWarning = true;
+ }
+ }
+ else
{
// Find all .yarnprojects in the root and create Projects out of
// them