Skip to content

Commit

Permalink
Avoid sending async updates on config update
Browse files Browse the repository at this point in the history
In
atom@7a5d727
the 'set-user-settings' callback was changed so that it nolonger
returned the promise created by `ConfigFile.update()`. This meant that
the logic in
[`ApplicateDelegate.onDidChangeUserSetting()`](https://github.com/atom/atom/blob/5f0231b/src/application-delegate.js#L193-L206) which uses
`.pendingSettingUpdateCount` to avoid triggering in response to calls to
ApplicationDelegate.setUserSettings` was no longer effective.

I noticed this when updating settings via the setting view. If you type
at just the right (wrong?) cadence, you'll notice that your input can
get updated with stale values.

Something like this:

```
You type            "a"      "b"            "c"
config.set          "a"      "ab"           "ac"
config.observe                        "a"         "ab"    "ac"
Input value         "a"      "ab"     "a"   "ac"  "ab"    "ac"
```

It's possible that is the same as atom/settings-view#1062

After this change typing in settings input seems to behave as expected.
  • Loading branch information
captbaritone committed Dec 5, 2018
1 parent aad7705 commit 878629d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main-process/atom-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ class AtomApplication extends EventEmitter {

this.disposable.add(ipcHelpers.respondTo('set-user-settings', (window, settings, filePath) => {
if (!this.quitting) {
ConfigFile.at(filePath || this.configFilePath).update(JSON.parse(settings))
return ConfigFile.at(filePath || this.configFilePath).update(JSON.parse(settings))
}
}))

Expand Down

0 comments on commit 878629d

Please sign in to comment.