From 9f85ba4f7d5c371fd3282d9aae95df7983bd15f6 Mon Sep 17 00:00:00 2001 From: probablycorey Date: Fri, 26 Apr 2013 10:07:27 -0700 Subject: [PATCH] Empty editors trigger config to delete the associated config key --- spec/app/config-panel-spec.coffee | 6 ++++-- src/app/config-panel.coffee | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/app/config-panel-spec.coffee b/spec/app/config-panel-spec.coffee index dd231eb2f..a1f9dabed 100644 --- a/spec/app/config-panel-spec.coffee +++ b/spec/app/config-panel-spec.coffee @@ -73,8 +73,10 @@ describe "ConfigPanel", -> expect(config.get('foo.float')).toBe 3.3 expect(config.get('foo.string')).toBe 'All limitations are self imposed.' - panel.intEditor.setText('') - panel.floatEditor.setText('ha ha') + panel.intEditor.setText('not an int') + panel.floatEditor.setText('not a float') + panel.stringEditor.setText('') window.advanceClock(10000) # wait for contents-modified to be triggered expect(config.get('foo.int')).toBe 0 expect(config.get('foo.float')).toBe 0 + expect(config.get('foo.string')).toBe undefined diff --git a/src/app/config-panel.coffee b/src/app/config-panel.coffee index 31b76b8b1..d884cea7d 100644 --- a/src/app/config-panel.coffee +++ b/src/app/config-panel.coffee @@ -43,4 +43,5 @@ class ConfigPanel extends View value = editor.getText() if type == 'int' then value = parseInt(value) or 0 if type == 'float' then value = parseFloat(value) or 0 + if value == "" then value = undefined config.set name, value