Repository: atom/atom
File: src/config.js (JavaScript)

Code before:
        this.setRawScopedValue(null, settings, source, scopeSelector)
      }
    })
  }

  /*
  Section: Private Scoped Settings
  */

  priorityForSource (source) {
    switch (source) {
      case this.mainSource:
        return 1000
      case this.projectFile:
        return 2000
      default:
        return 0
    }
  }

  emitChangeEvent () {
    if (this.transactDepth <= 0) { return this.emitter.emit('did-change') }
  }

  resetUserScopedSettings (newScopedSettings, options = {}) {
    const source = options.source == null ? this.mainSource : options.source
    const priority = this.priorityForSource(source)
    this.scopedSettingsStore.removePropertiesForSource(source)

    for (let scopeSelector in newScopedSettings) {
      let settings = newScopedSettings[scopeSelector]
      settings = this.makeValueConformToSchema(null, settings, {suppressException: true})
      const validatedSettings = {}
      validatedSettings[scopeSelector] = withoutEmptyObjects(settings)
      if (validatedSettings[scopeSelector] != null) { this.scopedSettingsStore.addProperties(source, validatedSettings, {priority}) }
    }

    return this.emitChangeEvent()
  }

  setRawScopedValue (keyPath, value, source, selector, options) {
    if (keyPath != null) {
      const newValue = {}
      setValueAtKeyPath(newValue, keyPath, value)
      value = newValue
    }

    const settingsBySelector = {}
    settingsBySelector[selector] = value
    this.scopedSettingsStore.addProperties(source, settingsBySelector, {priority: this.priorityForSource(source)})
    return this.emitChangeEvent()

Review comment (suggestion):
Maybe we should rename this to `resetScopedSettings` since it's not necessarily the user's settings any more.

Code after:
        settings = this.makeValueConformToSchema(null, settings, {suppressException: true})
        this.setRawScopedValue(null, settings, source, scopeSelector)
      }
    })
  }

  /*
  Section: Private Scoped Settings
  */

  priorityForSource (source) {
    switch (source) {
      case this.mainSource:
        return 1000
      case this.projectFile:
        return 2000
      default:
        return 0
    }
  }

  emitChangeEvent () {
    if (this.transactDepth <= 0) { return this.emitter.emit('did-change') }
  }

  resetScopedSettings (newScopedSettings, options = {}) {
    const source = options.source == null ? this.mainSource : options.source
    const priority = this.priorityForSource(source)
    this.scopedSettingsStore.removePropertiesForSource(source)

    for (let scopeSelector in newScopedSettings) {
      let settings = newScopedSettings[scopeSelector]
      settings = this.makeValueConformToSchema(null, settings, {suppressException: true})
      const validatedSettings = {}
      validatedSettings[scopeSelector] = withoutEmptyObjects(settings)
      if (validatedSettings[scopeSelector] != null) { this.scopedSettingsStore.addProperties(source, validatedSettings, {priority}) }
    }

    return this.emitChangeEvent()
  }

  setRawScopedValue (keyPath, value, source, selector, options) {
    if (keyPath != null) {
      const newValue = {}
      setValueAtKeyPath(newValue, keyPath, value)
      value = newValue
    }

    const settingsBySelector = {}
    settingsBySelector[selector] = value
    this.scopedSettingsStore.addProperties(source, settingsBySelector, {priority: this.priorityForSource(source)})