Skip to content

Project-specific settings cause diff view to show wrong value #738

@savetheclocktower

Description

@savetheclocktower

Describe the bug

Project-specific settings are a feature provided by both the project-config and atomic-management packages. They do this not through monkeypatching or any similar trick, but via APIs that have been in Atom since this PR landed three years ago. (Other packages may use these APIs as well, but these are the ones I know of.) My point is that this isn’t just a problem caused by a rogue package; it could just as easily be triggered by a user with a clever init-file.

The effect of these APIs is that sync-settings can’t necessarily trust atom.config.get to return settings as they exist in the user’s config.cson file. Any such setting may be modulated through a project’s own specific config overrides — which sync-settings can safely ignore, since those settings come with their own synchronization mechanism.

It turns out that sync-settings largely does the right thing here by checking atom.config.settings directly when deciding if settings have changed — but it still calls atom.config.get when building the diff view if those settings have changed. So in the case where you change a setting in your config.cson but your local project window has overridden that setting, the diff view will retrieve that project’s value instead of the right one. This further means that the diff view can show different results based on which window you run “View Diff” from.

I haven’t gone so far as to try to backup from a view that’s doing the wrong thing — I don’t know if the wrong value is sync’d.

To Reproduce

Steps to reproduce the behavior:

  1. Install project-config.
  2. Create an .atom/config.json file that overrides a setting in your config.cson. I’ll use this one as an example — assume the setting is 7 in both your config.cson and the remote backup:
{
  "zentabs": { "maximumOpenedTabs": 8 }
}
  1. Reload the window for that project.
  2. Open your config.cson and change the value to something completely new, like 9.
  3. Run the “Sync Settings: View Diff” command.
  4. You’ll see zentabs.maximumOpenedTabs: 8 as the local value.

Expected behavior

You ought to see zentabs.maximumOpenedTabs: 9.

Versions

  • OS: macOS 11.6.3
  • Atom: 1.59.0
  • APM: 2.6.2

Additional context

As far as I can tell, the fix here is simply never to call atom.config.get directly, and instead to use a utility function that behaves like Lodash’s get method but retrieves keys directly from atom.config.settings.

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