Fix wrap guide's font size subscription

This commit is contained in:
Nathan Sobo 2012-12-12 16:32:07 -08:00
parent ff468371ae
commit 8945a3f64b
2 changed files with 10 additions and 5 deletions

View File

@ -28,7 +28,7 @@ describe "WrapGuide", ->
expect(width).toBeGreaterThan(0)
expect(wrapGuide.position().left).toBe(width)
describe "font-size-change", ->
describe "when the font size changes", ->
it "updates the wrap guide position", ->
initial = wrapGuide.position().left
expect(initial).toBeGreaterThan(0)

View File

@ -22,15 +22,20 @@ class WrapGuide extends View
getGuideColumn: null
defaultColumn: 80
initialize: (@rootView, @editor, config = {}) =>
if typeof config.getGuideColumn is 'function'
@getGuideColumn = config.getGuideColumn
initialize: (@rootView, @editor, options = {}) =>
if typeof options.getGuideColumn is 'function'
@getGuideColumn = options.getGuideColumn
else
@getGuideColumn = (path, defaultColumn) -> defaultColumn
@updateGuide(@editor)
@editor.on 'editor-path-change', => @updateGuide(@editor)
@rootView.on 'font-size-change', => @updateGuide(@editor)
config.on 'update', => @setFontSize(config.editor.fontSize)
setFontSize: (fontSize) ->
return if fontSize == @fontSize
@fontSize = fontSize
@updateGuide(@editor)
updateGuide: (editor) ->
column = @getGuideColumn(editor.getPath(), @defaultColumn)