microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
226 stars 11 forks source link

[BUG] Double clicking C# Error in Unity does not open in active workspace #1481

Open otri opened 2 weeks ago

otri commented 2 weeks ago

Describe the Issue

Unity VS Code integration obscures control over the command line launch arguments in Unity AND it doesn't handle workspaces properly. Instead, its opens the Unity project solution with file:line:column, but this is a different window. This causes problems when dealing with package development. All the package code is outside of the active Unity's project's folder, the only way you can access that code is using a workspace.

This a really foundational feature regression since 2023 deprecation of the old Visual Studio Code Editor package.

Possible Solutions

VS Code Unity Extension Solution

EASIEST SOLUTION

Modify the alert to "Open in Workspace" to carry over the open file:line:column in the workspace.

More Thorough Solution

Detect a single file was opened and that there's an already opened enclosing workspace, seamlessly switch to opening the file in that active workspace.

Visual Studio Editor package Solution

I realize this would be an issue with Visual Studio Editor package in Unity, but it doesn't have a public facing github repo right now.

Allow command line launch arguments like:

--reuse-window --goto "$(File)":$(Line):$(Column)

OR consider launching VSCode via URL with:

vscode://file/{full path to file}:line:column

Steps To Reproduce

  1. Create a Unity project with local "file:../../Packages/com.example.foo" package
  2. Create a VS Code Workspace that includes the Unity project and "../../Packages/com.example.foo" folder.
  3. Open the VS Code Workspace
  4. Create "../../Packages/com.example.foo/Source/foo.cs" that has an error
  5. From Unity, try double clicking on the issue from foo.cs

Expected Behavior

Error should open in the active VS Code Workspace

Environment Information

jbevain commented 2 weeks ago

Related to #378

jbevain commented 2 weeks ago

An easy workaround while we're looking at how we want to support this is to take make the Visual Studio Editor package local to your Unity project and make the modifications you need there.