Use preferred line length as a *maximum* for soft wrapping

...if the softWrapAtPreferredLineLength config setting is enabled.
This commit is contained in:
Nathan Sobo
2016-06-16 08:42:30 -06:00
parent 56a9894896
commit 8a3d5f8534
2 changed files with 13 additions and 1 deletions

View File

@@ -6024,6 +6024,18 @@ describe "TextEditor", ->
it "sets the grammar", ->
expect(editor.getGrammar().name).toBe 'CoffeeScript'
describe "the softWrapAtPreferredLineLength config setting", ->
it "soft wraps the editor at the preferred line length unless the editor is narrower", ->
editor.setEditorWidthInChars(30)
atom.config.set('editor.softWrap', true)
atom.config.set('editor.softWrapAtPreferredLineLength', true)
atom.config.set('editor.preferredLineLength', 20)
expect(editor.lineTextForScreenRow(0)).toBe 'var quicksort = '
editor.setEditorWidthInChars(10)
expect(editor.lineTextForScreenRow(0)).toBe 'var '
describe "::getElement", ->
it "returns an element", ->
expect(editor.getElement() instanceof HTMLElement).toBe(true)

View File

@@ -2825,7 +2825,7 @@ class TextEditor extends Model
scopeDescriptor = @getRootScopeDescriptor()
if @isSoftWrapped()
if @config.get('editor.softWrapAtPreferredLineLength', scope: scopeDescriptor)
@config.get('editor.preferredLineLength', scope: scopeDescriptor)
Math.min(@getEditorWidthInChars(), @config.get('editor.preferredLineLength', scope: scopeDescriptor))
else
@getEditorWidthInChars()
else