Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Use preferred line length as a *maximum* for soft wrapping if softWrapAtPreferredLineLength is enabled #11991

Merged
merged 1 commit into from
Jun 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions spec/text-editor-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion src/text-editor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down