mirror of
https://github.com/atom/atom.git
synced 2026-02-16 09:35:54 -05:00
Default to 80 when editor.preferredLineLength <= 0
Previously any non-null value would be used as the target column in the wrap guide and autoflow packages when really 80 should have been used if the value was non-postive. Now config.getPositiveInt() is called with a default value of 80 if the current value isn't already positive.
This commit is contained in:
@@ -100,6 +100,24 @@ class Config
|
||||
_.valueForKeyPath(@settings, keyPath) ?
|
||||
_.valueForKeyPath(@defaultSettings, keyPath)
|
||||
|
||||
# Public: Retrieves the setting for the given key as an integer number.
|
||||
#
|
||||
# keyPath - The {String} name of the key to retrieve
|
||||
# Returns the value from Atom's default settings, the user's configuration file,
|
||||
# or `NaN` if the key doesn't exist in either.
|
||||
getInt: (keyPath, defaultValueWhenFalsy) ->
|
||||
parseInt(@get(keyPath))
|
||||
|
||||
# Public: Retrieves the setting for the given key as a positive integer number.
|
||||
#
|
||||
# keyPath - The {String} name of the key to retrieve
|
||||
# defaultValue - The integer {Number} to fall back to if the value isn't
|
||||
# positive
|
||||
# Returns the value from Atom's default settings, the user's configuration file,
|
||||
# or `defaultValue` if the key value isn't greater than zero.
|
||||
getPositiveInt: (keyPath, defaultValue) ->
|
||||
Math.max(@getInt(keyPath), 0) or defaultValue
|
||||
|
||||
# Public: Sets the value for a configuration setting.
|
||||
#
|
||||
# This value is stored in Atom's internal configuration file.
|
||||
|
||||
@@ -8,7 +8,7 @@ module.exports =
|
||||
editor.getBuffer().change(range, @reflow(editor.getTextInRange(range)))
|
||||
|
||||
reflow: (text) ->
|
||||
wrapColumn = config.get('editor.preferredLineLength') ? 80
|
||||
wrapColumn = config.getPositiveInt('editor.preferredLineLength', 80)
|
||||
lines = []
|
||||
|
||||
currentLine = []
|
||||
|
||||
@@ -19,7 +19,7 @@ class WrapGuideView extends View
|
||||
@subscribe $(window), 'resize', => @updateGuide()
|
||||
|
||||
getDefaultColumn: ->
|
||||
config.get('editor.preferredLineLength') ? 80
|
||||
config.getPositiveInt('editor.preferredLineLength', 80)
|
||||
|
||||
getGuideColumn: (path) ->
|
||||
customColumns = config.get('wrapGuide.columns')
|
||||
|
||||
Reference in New Issue
Block a user