Skip to content

Formatter settings not updated after edit #691

Open

Description

I edited a custom Eclipse formatter file so that brackets are on the same line for classes, methods, etc, and I have it added to my user settings json as:

"java.format.settings.url": "/Users/zeturk/Dropbox/MyEclipse.xml"

MyEclipse.xml file:
https://pastebin.com/raw/YvTtsMVW

but when I go back to a project and format the code, it is not updated to the settings specified (even if I reload or completely restart VSCode).

Any help is appreciated! (Sorry if this is an easy fix, pretty new to VSCode)

Environment
  • Operating System: MacOS

Activity

  1. snjeza commented on Oct 29, 2018

    @snjeza
    Collaborator

    I can't reproduce the issue.
    Could you check your workspace settings (<your_project>/.vscode/settings.json)?

  2. snjeza commented on Oct 29, 2018

    @snjeza
    Collaborator

    Could you attach your log (the contents of the Output view)?

  3. snjeza commented on Oct 29, 2018

    @snjeza
    Collaborator
  4. dlandis commented on Nov 23, 2020

    @dlandis

    I am also seeing this issue now.

    When you set "java.format.settings.url" to a local file, and then update the one of the settings in the xml file, the formatter doesn't pick that individual change up. Try changing one of settings in the xml file like:

    <setting id="org.eclipse.jdt.core.formatter.lineSplit" value="150"/>
    

    and then reformatting a java file. The line split won't change.

    However, if you create a totally new xml file and then point the "java.format.settings.url" to the new file, the new lineSplit will be used when you reformat next time. Hope that helps

  5. robstryker commented on Nov 2, 2026

    @robstryker
    Contributor

    The fix: commit 1400ad5d ("Link .settings directory to 'invisible project'", Apr 2021, #1579) restructured
    fileChanged() to check the formatter/settings URL match before the resource == null early return, and separately
    started linking such external config files into the invisible project so they're watchable. Current code
    (StandardProjectsManager.java:207-246) checks formatterUrl/settingsUrl against the changed URI up front, and only
    falls through to the resource-based build logic afterward — so an edit-in-place now correctly triggers
    configureSettings() regardless of whether the file is inside the workspace.

    So: real bug, root cause is the early-return-before-formatter-check ordering combined with getFileOrFolder failing on
    non-workspace paths, and it was fixed (likely incidentally, as part of unrelated invisible-project work) in 2021 —
    after the issue was filed but it looks like it was never explicitly closed/linked back to #691.

    @MeherSru Can you test this and verify it's not replicatable any longer?

    Primary repro (the original bug)

    1. Open a Java project in VS Code with vscode-java installed.
    2. Create a formatter XML file outside the workspace (e.g. ~/MyFormatter.xml or ~/Dropbox/MyEclipse.xml like the
      original reporter) — this is the key condition, since the bug only manifested for files not resolvable as an
      IResource inside the workspace.
    3. Set "java.format.settings.url" to the absolute path of that file (user or workspace settings).
    4. Format a Java file (Shift+Alt+F / Format Document) and confirm the formatter applies as expected (sanity check the
      setting works at all).
    5. Edit the XML in place — change a visible setting, e.g. org.eclipse.jdt.core.formatter.lineSplit to 150, or flip
      brace position/indentation style. Save the file.
    6. Without touching java.format.settings.url or reloading the window, format a Java file again.
      • Expected (fixed): the new formatting rule takes effect immediately.
      • Bug behavior: old formatting persists.

    Secondary checks (cover both watcher paths and regressions)

    1. Repeat steps 2–6 with the formatter file placed inside the workspace (e.g. .vscode/MyFormatter.xml) — this path
      worked even pre-fix, so it should still work and acts as a control.
    2. Test the delete/recreate case: delete the formatter file, confirm jdt.ls doesn't crash, recreate it with new
      content at the same path, and format again — this exercises registerWatchers() being re-invoked on CREATED/DELETED.
    3. Test java.format.settings.profile alongside the URL (multi-profile XML) — edit a setting within the active named
      profile and confirm it's picked up, since FormatterManager.readSettingsFromStream is profile-aware.
    4. Check the equivalent java.settings.url (Eclipse .prefs-style settings file, not just formatter) — same fileChanged
      code path handles both, so the same external-file edit test should be run there too.
    5. Cross-platform angle: since the original report was macOS and the bug involved path/URI resolution, it's worth
      running the same steps on Linux and Windows (path separators, case sensitivity, symlinks like ~/Dropbox) to make
      sure the fix isn't platform-specific.

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions