From f4b228c9087a8fdc2a9ce6f9c13e74c50069afae Mon Sep 17 00:00:00 2001 From: Machiste Quintana Date: Mon, 27 Apr 2015 18:25:01 -0400 Subject: [PATCH] Reset font size to window's starting font size --- spec/workspace-spec.coffee | 13 +++++++++++++ src/workspace.coffee | 6 ++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/spec/workspace-spec.coffee b/spec/workspace-spec.coffee index dac2849c0..7d8ea03b3 100644 --- a/spec/workspace-spec.coffee +++ b/spec/workspace-spec.coffee @@ -425,6 +425,19 @@ describe "Workspace", -> expect(atom.config.get('editor.fontSize')).toBe 1 workspace.decreaseFontSize() expect(atom.config.get('editor.fontSize')).toBe 1 + describe "::resetFontSize()", -> + it "resets the font size to the window's starting font size", -> + originalFontSize = 6 + + atom.config.set('editor.fontSize', originalFontSize) + workspace.increaseFontSize() + expect(atom.config.get('editor.fontSize')).toBe originalFontSize + 1 + workspace.resetFontSize() + expect(atom.config.get('editor.fontSize')).toBe originalFontSize + workspace.decreaseFontSize() + expect(atom.config.get('editor.fontSize')).toBe originalFontSize - 1 + workspace.resetFontSize() + expect(atom.config.get('editor.fontSize')).toBe originalFontSize describe "::openLicense()", -> it "opens the license as plain-text in a buffer", -> diff --git a/src/workspace.coffee b/src/workspace.coffee index 50c4117fb..7d460add0 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -612,16 +612,18 @@ 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 - # Restore to a default editor font size. + # Restore to the window's original editor font size. resetFontSize: -> - atom.config.unset("editor.fontSize") + atom.config.set("editor.fontSize", @originalFontSize) # Removes the item's uri from the list of potential items to reopen. itemOpened: (item) ->