microsoft / microsoft/vscode-java-pack

After opening a Java file, another file from a different project with same name becomes current file

Open
#410 4 comments 0 reactions 1 assignee View on GitHub

@testforstephen is already working on this.

Since May 29, 2020.

ai-triaged bug question
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:

  1. CTRL+SHIFT+P and selected "Java: Create New Project"
  2. Selected directory /home/username/Java
  3. Chose project name "HelloWorld"
    (Directory /home/username/Java/HelloWorld was created with default subdirectories and files, including ./src/App.java)
  4. CTRL+SHIFT+P and selected "Java: Create New Project"
  5. Selected directory /home/username/Java
  6. Chose project name "GoodbyeWorld"
    (Directory /home/username/Java/GoodbyeWorld was created with default subdirectories and files, including ./src/App.java)
  7. 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!"); } }
  8. Exited and reopened Visual Studio Code
  9. Navigated to the "GoodbyeWorld" project in the Explorer and opened "App.java"
  10. 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:

another-file-becomes-current-file

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.