mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
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:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user