diff --git a/spec/app/config-panel-spec.coffee b/spec/app/config-panel-spec.coffee index be8717246..0b56292b7 100644 --- a/spec/app/config-panel-spec.coffee +++ b/spec/app/config-panel-spec.coffee @@ -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() diff --git a/src/app/config-panel.coffee b/src/app/config-panel.coffee index 178248a90..663aa5697 100644 --- a/src/app/config-panel.coffee +++ b/src/app/config-panel.coffee @@ -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()))