mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add editor.softWrapAtPreferredLineLength config setting
This is used by the DisplayBuffer to use `editor.preferredLineLength` as the soft wrap column instead of the editor size.
This commit is contained in:
@@ -65,6 +65,21 @@ describe "DisplayBuffer", ->
|
||||
changeHandler.reset()
|
||||
|
||||
describe "rendering of soft-wrapped lines", ->
|
||||
describe "when editor.softWrapAtPreferredLineLength is set", ->
|
||||
it "uses the preferred line length as the soft wrap column when it is less than the configured soft wrap column", ->
|
||||
config.set('editor.preferredLineLength', 100)
|
||||
config.set('editor.softWrapAtPreferredLineLength', true)
|
||||
displayBuffer.updateWrappedScreenLines()
|
||||
expect(displayBuffer.lineForRow(10).text).toBe ' return '
|
||||
|
||||
config.set('editor.preferredLineLength', 5)
|
||||
displayBuffer.updateWrappedScreenLines()
|
||||
expect(displayBuffer.lineForRow(10).text).toBe 'funct'
|
||||
|
||||
config.set('editor.softWrapAtPreferredLineLength', false)
|
||||
displayBuffer.updateWrappedScreenLines()
|
||||
expect(displayBuffer.lineForRow(10).text).toBe ' return '
|
||||
|
||||
describe "when the line is shorter than the max line length", ->
|
||||
it "renders the line unchanged", ->
|
||||
expect(displayBuffer.lineForRow(0).text).toBe buffer.lineForRow(0)
|
||||
|
||||
@@ -415,6 +415,8 @@ class DisplayBuffer
|
||||
# Returns a {Number} representing the `line` position where the wrap would take place.
|
||||
# Returns `null` if a wrap wouldn't occur.
|
||||
findWrapColumn: (line, softWrapColumn=@getSoftWrapColumn()) ->
|
||||
if config.get('editor.softWrapAtPreferredLineLength')
|
||||
softWrapColumn = Math.min(softWrapColumn, config.getPositiveInt('editor.preferredLineLength', softWrapColumn))
|
||||
return unless @getSoftWrap()
|
||||
return unless line.length > softWrapColumn
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ class Editor extends View
|
||||
tabLength: 2
|
||||
softWrap: false
|
||||
softTabs: true
|
||||
softWrapAtPreferredLineLength: false
|
||||
|
||||
@nextEditorId: 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user