diff --git a/spec/workspace-spec.coffee b/spec/workspace-spec.coffee index 61da334bb..9b8ce4d50 100644 --- a/spec/workspace-spec.coffee +++ b/spec/workspace-spec.coffee @@ -428,7 +428,7 @@ describe "Workspace", -> describe "::resetFontSize()", -> it "resets the font size to the window's starting font size", -> - originalFontSize = 6 + originalFontSize = atom.config.get('editor.fontSize') atom.config.set('editor.fontSize', originalFontSize) workspace.increaseFontSize() @@ -441,12 +441,22 @@ describe "Workspace", -> expect(atom.config.get('editor.fontSize')).toBe originalFontSize it "does nothing if the font size has not been changed", -> - originalFontSize = 6 + originalFontSize = atom.config.get('editor.fontSize') atom.config.set('editor.fontSize', originalFontSize) workspace.resetFontSize() expect(atom.config.get('editor.fontSize')).toBe originalFontSize + it "resets the font size when the editor's font size changes", -> + originalFontSize = atom.config.get('editor.fontSize') + + atom.config.set('editor.fontSize', originalFontSize + 1) + workspace.resetFontSize() + expect(atom.config.get('editor.fontSize')).toBe originalFontSize + atom.config.set('editor.fontSize', originalFontSize - 1) + workspace.resetFontSize() + expect(atom.config.get('editor.fontSize')).toBe originalFontSize + describe "::openLicense()", -> it "opens the license as plain-text in a buffer", -> waitsForPromise -> workspace.openLicense() diff --git a/src/workspace.coffee b/src/workspace.coffee index 2f70e4316..07040463b 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -75,6 +75,8 @@ class Workspace extends Model atom.views.addViewProvider Panel, (model) -> new PanelElement().initialize(model) + @subscribeToFontSize() + # Called by the Serializable mixin during deserialization deserializeParams: (params) -> for packageName in params.packagesWithActiveGrammars ? [] @@ -612,12 +614,10 @@ class Workspace extends Model # Increase the editor font size by 1px. increaseFontSize: -> - @originalFontSize ?= atom.config.get("editor.fontSize") atom.config.set("editor.fontSize", atom.config.get("editor.fontSize") + 1) # Decrease the editor font size by 1px. decreaseFontSize: -> - @originalFontSize ?= atom.config.get("editor.fontSize") fontSize = atom.config.get("editor.fontSize") atom.config.set("editor.fontSize", fontSize - 1) if fontSize > 1 @@ -626,6 +626,10 @@ class Workspace extends Model if @originalFontSize atom.config.set("editor.fontSize", @originalFontSize) + subscribeToFontSize: -> + atom.config.onDidChange 'editor.fontSize', ({newValue, oldValue}) => + @originalFontSize ?= oldValue + # Removes the item's uri from the list of potential items to reopen. itemOpened: (item) -> if typeof item.getURI is 'function'