Skip to content

Java Projects tree duplicates or misplaces projects in multi-root workspaces #1060

Description

@wenytang-ms

Related to redhat-developer/vscode-java#4478

Reproduction

  1. Open a Maven/Java project and wait for project import to complete.
  2. Add a non-Java folder (for example, an Angular project) to the multi-root workspace.
  3. Open the JAVA PROJECTS view.

Actual behavior

The Java project can temporarily or persistently appear twice, appear directly at the tree root, or be associated with an incorrect workspace-folder hierarchy.

Expected behavior

Each Java project should appear once under its corresponding workspace folder. The non-Java workspace folder should not contain that Java project.

Root cause

This appears to be a regression from progressive project loading introduced by #982:

  • onDidProjectsImport routes projects to addProgressiveProjects() even after the language server is fully ready.
  • addProgressiveProjects() appends ProjectNode directly to root items and does not preserve the WorkspaceNode -> ProjectNode structure required by multi-root workspaces.
  • Deduplication compares raw URI strings. On Windows, equivalent URIs such as file:/C:/project and file:///c%3A/project are treated as different projects.
  • The progressive update can race with the debounced workspace-folder refresh, leaving duplicate or mixed root nodes.

The java.project.list result itself is correct: the non-Java folder returns no projects and the Java folder returns one project.

Suggested fix

  • Use progressive insertion only before full server readiness; refresh normally afterward.
  • Preserve workspace-folder grouping, or disable progressive insertion for multi-root workspaces.
  • Deduplicate using a normalized Uri.fsPath.
  • Add a regression test covering adding a non-Java folder after a Java project has loaded.

Reproduced on Windows with Project Manager for Java 0.27.2026062300 and Language Support for Java 1.56.2026080608.

Related: #758

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions