mirror of
https://github.com/atom/atom.git
synced 2026-02-16 17:45:24 -05:00
Use editor.preferredLineLength as default column
This config value will be used when no custom column exists for the current path.
This commit is contained in:
@@ -11,23 +11,24 @@ class WrapGuideView extends View
|
||||
@content: ->
|
||||
@div class: 'wrap-guide'
|
||||
|
||||
defaultColumn: 80
|
||||
|
||||
initialize: (@editor) ->
|
||||
@observeConfig 'editor.fontSize', => @updateGuide()
|
||||
@subscribe @editor, 'editor:path-changed', => @updateGuide()
|
||||
@subscribe @editor, 'editor:min-width-changed', => @updateGuide()
|
||||
@subscribe $(window), 'resize', => @updateGuide()
|
||||
|
||||
getDefaultColumn: ->
|
||||
config.get('editor.preferredLineLength') ? 80
|
||||
|
||||
getGuideColumn: (path) ->
|
||||
customColumns = config.get('wrapGuide.columns')
|
||||
return @defaultColumn unless _.isArray(customColumns)
|
||||
return @getDefaultColumn() unless _.isArray(customColumns)
|
||||
for customColumn in customColumns
|
||||
continue unless _.isObject(customColumn)
|
||||
pattern = customColumn['pattern']
|
||||
continue unless pattern
|
||||
return parseInt(customColumn['column']) if new RegExp(pattern).test(path)
|
||||
@defaultColumn
|
||||
@getDefaultColumn()
|
||||
|
||||
updateGuide: ->
|
||||
column = @getGuideColumn(@editor.getPath(), @defaultColumn)
|
||||
|
||||
Reference in New Issue
Block a user