microsoft / microsoft/vscode-java-pack
After opening a Java file, another file from a different project with same name becomes current file
@testforstephen is already working on this.
Since May 29, 2020.
- Dominant language
- TypeScript
- Stars
- 352
- Forks
- 166
- Avg merge
- 17h 47m
- Merged PRs (30d)
- 32
Description
After creating two new projects using "Java: Create New Project", opening the default "App.java" of the second project and running it from the CodeLens options results in the "App.java" from the first project being run. The first project shows as the "current file" in the explorer (it is in yellow text) even though the second project was the one opened from Explorer. I have attached a GIF demonstrating the issue, with reproduction steps below.
I am using Visual Studio Code 1.45.1 + WSL Ubuntu (20.04 LTS build 20200423) with the Remote - WSL and the Java Extension Packs installed.
Reproduced with the following steps:
- CTRL+SHIFT+P and selected "Java: Create New Project"
- Selected directory /home/username/Java
- Chose project name "HelloWorld"
(Directory /home/username/Java/HelloWorld was created with default subdirectories and files, including ./src/App.java) - CTRL+SHIFT+P and selected "Java: Create New Project"
- Selected directory /home/username/Java
- Chose project name "GoodbyeWorld"
(Directory /home/username/Java/GoodbyeWorld was created with default subdirectories and files, including ./src/App.java) - Modified file /home/username/Java/GoodbyeWorld/src/App.java to print "Goodbye, World!" to the console (instead of "Hello, World!")
public class App { public static void main(String[] args) throws Exception { System.out.println("Goodbye, World!"); } } - Exited and reopened Visual Studio Code
- Navigated to the "GoodbyeWorld" project in the Explorer and opened "App.java"
- Confirmed the code should print "Goodbye, World!" and clicked the "Run" CodeLens option
Output: "Hello, World!"
Explorer now shows the HelloWorld project is in yellow text, and navigating the subdirectories shows /home/username/Java/HelloWorld/src/App.java is highlighted
I am new to Visual Studio Code, I apologize if this is simply a configuration error on my part. I followed the https://code.visualstudio.com/docs/remote/wsl and https://code.visualstudio.com/docs/java/java-tutorial for my setup.
Video demonstration:

Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.