mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-14 04:29:04 +03:00
Max line length is preserved when a new buffer is assigned to an editor.
This commit is contained in:
parent
fb915f9c1c
commit
68bd79f8c2
@ -106,6 +106,12 @@ describe "Editor", ->
|
||||
expect(editor.lines.find('.line:eq(5)').text()).toBe " while(items.length > 0) {"
|
||||
expect(editor.bufferPositionForScreenPosition(editor.getCursorScreenPosition())).toEqual [3, 60]
|
||||
|
||||
it "wraps the lines of any newly assigned buffers", ->
|
||||
otherBuffer = new Buffer
|
||||
otherBuffer.setText([1..100].join(''))
|
||||
editor.setBuffer(otherBuffer)
|
||||
expect(editor.lines.find('.line').length).toBeGreaterThan(1)
|
||||
|
||||
it "unwraps lines and cancels window resize listener when softwrap is disabled", ->
|
||||
editor.toggleSoftWrap()
|
||||
expect(editor.lines.find('.line:eq(3)').text()).toBe ' var pivot = items.shift(), current, left = [], right = [];'
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user