mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Ignore first modified event in config editor
This event comes from initially setting the text for the current config value on the editor and was causing the config to be immediately saved multiple times when opened.
This commit is contained in:
@@ -67,6 +67,7 @@ describe "ConfigPanel", ->
|
||||
config.set('foo.float', 1.1)
|
||||
config.set('foo.string', 'I think therefore I am.')
|
||||
panel = new TestPanel
|
||||
window.advanceClock(10000) # wait for contents-modified to be triggered
|
||||
expect(panel.intEditor.getText()).toBe '1'
|
||||
expect(panel.floatEditor.getText()).toBe '1.1'
|
||||
expect(panel.stringEditor.getText()).toBe 'I think therefore I am.'
|
||||
@@ -100,3 +101,15 @@ describe "ConfigPanel", ->
|
||||
expect(config.get('foo.int')).toBe undefined
|
||||
expect(config.get('foo.float')).toBe undefined
|
||||
expect(config.get('foo.string')).toBe undefined
|
||||
|
||||
it "does not save the config value until it has been changed to a new value", ->
|
||||
class TestPanel extends ConfigPanel
|
||||
@content: ->
|
||||
@div =>
|
||||
@subview "foo.int", new Editor(mini: true, attributes: {id: 'foo.int', type: 'int'})
|
||||
|
||||
config.set('foo.int', 1)
|
||||
spyOn(config, 'set')
|
||||
new TestPanel
|
||||
window.advanceClock(10000) # wait for contents-modified to be triggered
|
||||
expect(config.set).not.toHaveBeenCalled()
|
||||
|
||||
@@ -48,5 +48,6 @@ class ConfigPanel extends View
|
||||
value ?= ""
|
||||
editor.setText(value.toString())
|
||||
|
||||
editor.getBuffer().on 'contents-modified', =>
|
||||
config.set(name, @parseValue(type, editor.getText()))
|
||||
editor.getBuffer().one 'contents-modified', =>
|
||||
editor.getBuffer().on 'contents-modified', =>
|
||||
config.set(name, @parseValue(type, editor.getText()))
|
||||
|
||||
Reference in New Issue
Block a user