Skip to content

#2509: merge VSCode user settings template into --user-data-dir - #2526

Open
quando632 wants to merge 5 commits into
devonfw:mainfrom
quando632:feature/2509-vscode-user-settings-merge
Open

quando632 wants to merge 5 commits into
devonfw:mainfrom
quando632:feature/2509-vscode-user-settings-merge

Conversation

@quando632

@quando632 quando632 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

This PR fixes #2509

Since #2174 VSCode is started with --user-data-dir=$IDE_HOME/.ide/vscode/«workspace»/config, but the settings repositories still provide the user settings template as vscode/workspace/*/.vscode/.userdata/User/settings.json. The workspace merge kept writing it to «workspace»/.vscode/.userdata, which VSCode no longer reads. As a result, the user settings were silently ignored (e.g. telemetry was on again and update.mode: none was not applied), and .vscode/.userdata was recreated in every workspace.

Implemented changes:

  • IdeToolCommandlet: new hook getWorkspaceRedirects(Path) so an IDE can merge template sub-folders to a different location than the workspace. The default redirects nothing.
  • DirectoryMerger: new merge(..., Map<Path, Path> redirects) overload that applies these redirects while traversing the templates. The existing merge delegates to it with an empty map.
  • Vscode:
    • Redirects «workspace»/.vscode/.userdata to the user-data folder passed via --user-data-dir. Existing settings repositories keep working unchanged. All other .vscode templates are still merged into the workspace.
    • Before configuring the workspace, removes a leftover «workspace»/.vscode/.userdata folder:
      • If the user-data folder does not exist yet, the leftover is moved there.
      • Otherwise it is backed up to $IDE_HOME/backups, so nothing is deleted.
    • This also covers SNAPSHOT users who already ran Mig202609002, since a migration does not run twice.
  • Tests in VscodeTest for the redirected merge and for both cleanup cases.

Not in scope: with VSCODE_PROFILE_ENABLED the user settings are still not applied (#2058, different cause).

No CHANGELOG entry: the bug was introduced by #2174, which has not been released yet (2026.09.002), so per DoD it is not listed separately.


Testing instructions

  1. Build IDEasy from this branch and use a project whose settings contain vscode/workspace/update/.vscode/.userdata/User/settings.json (e.g. the default ide-settings).
  2. Run ide vscode in a workspace.
  3. Verify:
    • «workspace»/.vscode/.userdata is not created.
    • $IDE_HOME/.ide/vscode/«workspace»/config/User/settings.json contains the settings from the template.
    • In VSCode, telemetry.telemetryLevel is off and update.mode is none.
  4. Create a folder «workspace»/.vscode/.userdata manually and run ide vscode again. The folder is removed from the workspace and appears under $IDE_HOME/backups/….

Checklist for this PR

Make sure everything is checked before merging this PR. For further info please also see
our DoD.

  • When running mvn clean test locally all tests pass and build is successful
  • PR title is of the form #«issue-id»: «brief summary» (e.g. #921: fixed setup.bat and not feature/921 fixed setup.bat). If no issue ID exists, title only.
  • PR top-level comment summaries what has been done and contains link to addressed issue(s)
  • PR and issue(s) have suitable labels
  • Issue is set to In Progress and assigned to you or there is no issue (might happen for very small PRs)
  • You followed all coding conventions
  • You have added the issue implemented by your PR in CHANGELOG.adoc unless issue is labelled
    with internal (not needed: fixes an unreleased regression of VSCode: store metadata under $IDE_HOME/.ide/vscode/<workspace> + migration #2174, see DoD)
  • You have not changed any dependency in pom.xml files or otherwise if runtime dependencies changed, you have updated our LICENSE.asciidoc
  • You have formulated clear instructions on how to test your contribution under "Testing instructions"

The settings repositories provide the VSCode user settings template as
.vscode/.userdata, which is no longer read by VSCode since devonfw#2174 moved the
user-data to $IDE_HOME/.ide/vscode/«workspace»/config. The workspace merge now
redirects this folder to the user-data folder, and a stale .vscode/.userdata
left in the workspace is moved there or backed up.
@github-project-automation github-project-automation Bot moved this to 🆕 New in IDEasy board Sep 21, 2026
@quando632 quando632 added settings ide-settings repo and replated processes and features vscode Microsoft visual studio code workspace workspaces sub-folder to manage sub-projects labels Sep 21, 2026
@coveralls

coveralls commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 35704748924

Coverage increased (+0.03%) to 74.162%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 30 coverage regressions across 4 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

30 previously-covered lines in 4 files lost coverage.

File Lines Losing Coverage Coverage
com/devonfw/tools/ide/merge/DirectoryMerger.java 20 66.67%
com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java 5 88.89%
com/devonfw/tools/ide/tool/vscode/Vscode.java 4 89.61%
com/devonfw/tools/ide/version/VersionSegment.java 1 91.08%

Coverage Stats

Coverage Status
Relevant Lines: 19137
Covered Lines: 14830
Line Coverage: 77.49%
Relevant Branches: 8563
Covered Branches: 5713
Branch Coverage: 66.72%
Branches in Coverage %: Yes
Coverage Strength: 3.32 hits per line

💛 - Coveralls

@hohwille hohwille left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quando632 thanks for quickly taking this up. 👍 I left some quick review feedback.

Comment thread cli/src/main/java/com/devonfw/tools/ide/tool/vscode/Vscode.java Outdated
// the settings still provide the user settings template in the legacy location inside the workspace
return Map.of(workspaceFolder.resolve(LEGACY_USER_DATA), getUserDataPath());
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LEGACY_USER_DATA is a Path containing of 2 folders while your merger adoption seems to handle only the current filename.
I would rather fix this without changing DirectoryMerger by changing the 3 path arguments passed to it.
So you could simply change the visibility of this method and override it for VSCode and Intellij/IdeaBasedIdeCommandlet:

private int mergeWorkspace(Path configFolder, Path workspaceFolder, int errors) {

If we do not want to change the directory structure below getIdeMetadataPath(), you would need to keep the knowledge of the ".vscode" (and potentially also ".userdata") folder and navigating into that for the update/setup path. Otherwise things might remain even more simple if we just keep the old structure and only relocate from getWorkspacePath() to getIdeMetadataPath() or is that not possible with this --user-data-dir option and we still have other bugs?

@quando632 quando632 Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point to double-check. The nested path is handled: DirectoryMerger looks up the full target path on every level, so «workspace»/.vscode stays as is and only «workspace»/.vscode/.userdata is redirected. VscodeTest.testConfigureWorkspaceMergesUserDataTemplateIntoUserDataFolder covers this (verified locally: without the redirect it fails).

The reason for the redirect is that one template folder has to end up in two places. ide-settings ships both .vscode/settings.json, which VSCode reads from the workspace, and .vscode/.userdata/User/settings.json, which has to go to --user-data-dir. Relocating everything to getIdeMetadataPath() would break the workspace settings. Only adjusting the paths passed to the merger would mean walking the template folders manually to leave .userdata out. The existing merge signature stays unchanged.

For IntelliJ, idea.properties and .intellij/config are still written to and read from the workspace consistently, so nothing is broken there.

@hohwille hohwille added this to the release:2026.09.002 milestone Sep 21, 2026
@QuangAnhLe QuangAnhLe added QA approved Label a PR that has been re-testet via nightly SNAPSHOT after merge and commented. and removed QA approved Label a PR that has been re-testet via nightly SNAPSHOT after merge and commented. labels Sep 22, 2026
@QuangAnhLe QuangAnhLe moved this from 🆕 New to Team Review in IDEasy board Sep 22, 2026
@quando632
quando632 marked this pull request as ready for review September 22, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

settings ide-settings repo and replated processes and features vscode Microsoft visual studio code workspace workspaces sub-folder to manage sub-projects

Projects

Status: Team Review

Development

Successfully merging this pull request may close these issues.

VSCode user settings from the settings repository are ignored since user-data moved to $IDE_HOME/.ide

4 participants