mirror of
https://github.com/atom/atom.git
synced 2026-02-09 14:15:24 -05:00
Max line length is preserved when a new buffer is assigned to an editor.
This commit is contained in:
@@ -196,7 +196,7 @@ class Editor extends View
|
||||
@trigger 'buffer-path-change'
|
||||
@buffer.on "path-change.editor#{@id}", => @trigger 'buffer-path-change'
|
||||
|
||||
@renderer = new Renderer(@buffer)
|
||||
@renderer = new Renderer(@buffer, { maxLineLength: @calcMaxLineLength() })
|
||||
@renderLines()
|
||||
@gutter.renderLineNumbers()
|
||||
|
||||
@@ -277,13 +277,14 @@ class Editor extends View
|
||||
toggleSoftWrap: ->
|
||||
@setSoftWrap(not @softWrap)
|
||||
|
||||
setMaxLineLength: (maxLineLength) ->
|
||||
maxLineLength ?=
|
||||
if @softWrap
|
||||
Math.floor(@scroller.width() / @charWidth)
|
||||
else
|
||||
Infinity
|
||||
calcMaxLineLength: ->
|
||||
if @softWrap
|
||||
Math.floor(@scroller.width() / @charWidth)
|
||||
else
|
||||
Infinity
|
||||
|
||||
setMaxLineLength: (maxLineLength) ->
|
||||
maxLineLength ?= @calcMaxLineLength()
|
||||
@renderer.setMaxLineLength(maxLineLength) if maxLineLength
|
||||
|
||||
createFold: (range) ->
|
||||
@@ -406,7 +407,6 @@ class Editor extends View
|
||||
|
||||
foldSelection: -> @getSelection().fold()
|
||||
|
||||
|
||||
undo: ->
|
||||
@buffer.undo()
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ class Renderer
|
||||
lastHighlighterChangeEvent: null
|
||||
foldPlaceholderLength: 3
|
||||
|
||||
constructor: (@buffer) ->
|
||||
constructor: (@buffer, options={}) ->
|
||||
@id = @constructor.idCounter++
|
||||
@highlighter = new Highlighter(@buffer)
|
||||
@maxLineLength = Infinity
|
||||
@maxLineLength = options.maxLineLength ? Infinity
|
||||
@activeFolds = {}
|
||||
@foldsById = {}
|
||||
@buildLineMap()
|
||||
|
||||
Reference in New Issue
Block a user