godotengine / godot-vscode-plugin

Godot development tools for VSCode
MIT License
1.53k stars 151 forks source link

Unnecessary "Couldn't connect to GDScript language server" when in non-Godot workspace #696

Open Gaiko-sw opened 3 weeks ago

Gaiko-sw commented 3 weeks ago

Godot version

4.2.2 stable

VS Code version

1.89.1

Godot Tools VS Code extension version

2.1.0

System information

Ubuntu 24.04

Issue description

When opening a non-Godot workspace in VSCode, the Godot extension still generates a notification that "the GDScript language server isn't available", even though it isn't necessary.

The notification should still pop up if it's detected that this workspace is a Godot project.

Steps to reproduce

DaelonSuzuka commented 3 weeks ago

The extension should only be activated if you open a Godot file or if it find a project.godot in the workspace. Do you have any tabs open from the previous workspace with .tscn, .gdscript, .tres, .res, .import, or .gdshader files? (this list is from memory and may not be exactly correct)

Calinou commented 3 weeks ago

I think opening a .gd file in a workspace that lacks a project.godot file shouldn't attempt connecting to a LSP, but this is prone to false negatives if your workspace root is a subfolder of the project root.

Gaiko-sw commented 3 weeks ago

At the moment I think opening a Godot project first and then opening a (non-Godot) C# project straight after might trigger it, and then again even if you close and reopen Code.

Do .cs files trigger the extension? Is it possible that they only trigger it with a project.godot file, and the extension hasn't realised I've changed to a non-Godot C# project?

I thought it also happened in other workspaces but I can't reproduce it now.

DaelonSuzuka commented 3 weeks ago

Are you using the Godot C# extension also?

ParadoxV5 commented 3 days ago

“Copy Resource Path” option appears in the right click menu of tabs in non-Godot project files as well. (Mis)clicking it easily raises “Current workspace is not a Godot project” and/or “Couldn't connect to GDScript language server”.