mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-10-27 11:42:41 +03:00
Fix soft wrapping when editorWidthInChars is used
This commit is contained in:
parent
fffcfb3405
commit
b198acc995
@ -2132,6 +2132,12 @@ describe "TextEditorPresenter", ->
|
||||
expectValues lineNumberStateForScreenRow(presenter, 6), {screenRow: 6, bufferRow: 3, softWrapped: true}
|
||||
expectValues lineNumberStateForScreenRow(presenter, 7), {screenRow: 7, bufferRow: 4, softWrapped: false}
|
||||
|
||||
presenter.setContentFrameWidth(500)
|
||||
|
||||
expectValues lineNumberStateForScreenRow(presenter, 5), {screenRow: 5, bufferRow: 4, softWrapped: false}
|
||||
expectValues lineNumberStateForScreenRow(presenter, 6), {screenRow: 6, bufferRow: 5, softWrapped: false}
|
||||
expectValues lineNumberStateForScreenRow(presenter, 7), {screenRow: 7, bufferRow: 6, softWrapped: false}
|
||||
|
||||
describe ".decorationClasses", ->
|
||||
it "adds decoration classes to the relevant line number state objects, both initially and when decorations change", ->
|
||||
marker1 = editor.markBufferRange([[4, 0], [6, 2]], invalidate: 'touch', maintainHistory: true)
|
||||
|
@ -198,13 +198,13 @@ class DisplayBuffer extends Model
|
||||
setVerticalScrollbarWidth: (@verticalScrollbarWidth) -> @verticalScrollbarWidth
|
||||
|
||||
getHeight: ->
|
||||
@height or 0
|
||||
@height
|
||||
|
||||
setHeight: (@height) ->
|
||||
@height
|
||||
|
||||
getWidth: ->
|
||||
@width or 0
|
||||
@width
|
||||
|
||||
setWidth: (newWidth) ->
|
||||
oldWidth = @width
|
||||
|
@ -32,6 +32,7 @@ class TextEditorPresenter
|
||||
@lineNumberDecorationsByScreenRow = {}
|
||||
@customGutterDecorationsByGutterNameAndScreenRow = {}
|
||||
@transferMeasurementsToModel()
|
||||
@transferMeasurementsFromModel()
|
||||
@observeModel()
|
||||
@observeConfig()
|
||||
@buildState()
|
||||
@ -53,6 +54,9 @@ class TextEditorPresenter
|
||||
@model.setLineHeightInPixels(@lineHeight) if @lineHeight?
|
||||
@model.setDefaultCharWidth(@baseCharacterWidth) if @baseCharacterWidth?
|
||||
|
||||
transferMeasurementsFromModel: ->
|
||||
@editorWidthInChars = @model.getEditorWidthInChars()
|
||||
|
||||
# Private: Determines whether {TextEditorPresenter} is currently batching changes.
|
||||
# Returns a {Boolean}, `true` if is collecting changes, `false` if is applying them.
|
||||
isBatching: ->
|
||||
@ -677,7 +681,6 @@ class TextEditorPresenter
|
||||
@updateScrollHeight()
|
||||
|
||||
if @contentWidth isnt oldContentWidth
|
||||
@model.setWidth(Math.min(@clientWidth, @contentWidth))
|
||||
@updateScrollbarDimensions()
|
||||
@updateScrollWidth()
|
||||
|
||||
@ -685,9 +688,10 @@ class TextEditorPresenter
|
||||
return unless @height? and @horizontalScrollbarHeight?
|
||||
|
||||
clientHeight = @height - @horizontalScrollbarHeight
|
||||
@model.setHeight(clientHeight)
|
||||
|
||||
unless @clientHeight is clientHeight
|
||||
@clientHeight = clientHeight
|
||||
@model.setHeight(@clientHeight)
|
||||
@updateScrollHeight()
|
||||
@updateScrollTop()
|
||||
|
||||
@ -695,9 +699,10 @@ class TextEditorPresenter
|
||||
return unless @contentFrameWidth? and @verticalScrollbarWidth?
|
||||
|
||||
clientWidth = @contentFrameWidth - @verticalScrollbarWidth
|
||||
@model.setWidth(clientWidth) unless @editorWidthInChars
|
||||
|
||||
unless @clientWidth is clientWidth
|
||||
@clientWidth = clientWidth
|
||||
@model.setWidth(Math.min(@clientWidth, @contentWidth))
|
||||
@updateScrollWidth()
|
||||
@updateScrollLeft()
|
||||
|
||||
@ -941,9 +946,10 @@ class TextEditorPresenter
|
||||
@updateEndRow()
|
||||
|
||||
setContentFrameWidth: (contentFrameWidth) ->
|
||||
unless @contentFrameWidth is contentFrameWidth
|
||||
if @contentFrameWidth isnt contentFrameWidth or @editorWidthInChars?
|
||||
oldContentFrameWidth = @contentFrameWidth
|
||||
@contentFrameWidth = contentFrameWidth
|
||||
@editorWidthInChars = null
|
||||
@updateScrollbarDimensions()
|
||||
@updateClientWidth()
|
||||
@shouldUpdateVerticalScrollState = true
|
||||
|
@ -554,6 +554,10 @@ class TextEditor extends Model
|
||||
setEditorWidthInChars: (editorWidthInChars) ->
|
||||
@displayBuffer.setEditorWidthInChars(editorWidthInChars)
|
||||
|
||||
# Returns the editor width in characters.
|
||||
getEditorWidthInChars: ->
|
||||
@displayBuffer.getEditorWidthInChars()
|
||||
|
||||
###
|
||||
Section: File Details
|
||||
###
|
||||
|
Loading…
Reference in New Issue
Block a user