Merge pull request #11991 from atom/ns-as-fix-soft-wrap-at-preferred-line-length

Use preferred line length as a *maximum* for soft wrapping if softWrapAtPreferredLineLength is enabled
This commit is contained in:
Antonio Scandurra
2016-06-17 11:14:31 +02:00
committed by GitHub
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