diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index eb7494738..8a9811704 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -551,13 +551,26 @@ describe "Editor", -> expect(editor.verticalScrollbarContent.height()).toBe buffer.getLineCount() * editor.lineHeight describe "font size", -> - it "sets the initial font size based on the value from config", -> - config.set("editor.fontSize", 20) - newEditor = editor.splitRight() - expect(editor.css('font-size')).toBe '20px' - expect(newEditor.css('font-size')).toBe '20px' + beforeEach -> + expect(editor.css('font-size')).not.toBe "20px" + + it "sets the initial font size based on the value from config", -> + expect($("head style.font-size")).toExist() + expect($("head style.font-size").text()).toMatch "{font-size: #{config.get('editor.fontSize')}px}" + + describe "when the font size changes", -> + it "updates the font family on new and existing editors", -> + rootView.attachToDom() + rootView.height(200) + rootView.width(200) + + config.set("editor.fontSize", 20) + newEditor = editor.splitRight() + + expect($("head style.font-size").text()).toMatch "{font-size: 20px}" + expect(editor.css('font-size')).toBe '20px' + expect(newEditor.css('font-size')).toBe '20px' - describe "when the font size changes on the view", -> it "updates the font sizes of editors and recalculates dimensions critical to cursor positioning", -> rootView.attachToDom() rootView.height(200) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index a45e1c636..a4dd22579 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -683,9 +683,14 @@ class Editor extends View @save() if @getPath()? setFontSize: (@fontSize) -> - if fontSize? - @css('font-size', fontSize + 'px') - @redraw() + headTag = $("head") + styleTag = headTag.find("style.font-size") + if styleTag.length == 0 + styleTag = $$ -> @style class: 'font-size' + headTag.append styleTag + + styleTag.text(".editor {font-size: #{@fontSize}px}") + @redraw() getFontSize: -> @fontSize