mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-10-27 11:42:41 +03:00
Stop reporting scroll positions to the model
This commit is contained in:
parent
fda981ed1d
commit
60fdd3793f
@ -3461,7 +3461,8 @@ describe "TextEditorComponent", ->
|
||||
|
||||
wrapperNode.setScrollTop(0)
|
||||
wrapperNode.scrollToCursorPosition(center: false)
|
||||
expect(editor.getScrollBottom()).toBe (8 + editor.getVerticalScrollMargin()) * 10
|
||||
expect(wrapperNode.getScrollTop()).toBe (7.8 - editor.getVerticalScrollMargin()) * 10
|
||||
expect(wrapperNode.getScrollBottom()).toBe (9.3 + editor.getVerticalScrollMargin()) * 10
|
||||
|
||||
describe "moving cursors", ->
|
||||
it "scrolls down when the last cursor gets closer than ::verticalScrollMargin to the bottom of the editor", ->
|
||||
|
@ -5,7 +5,7 @@ TextBuffer = require 'text-buffer'
|
||||
TextEditor = require '../src/text-editor'
|
||||
TextEditorPresenter = require '../src/text-editor-presenter'
|
||||
|
||||
describe "TextEditorPresenter", ->
|
||||
fdescribe "TextEditorPresenter", ->
|
||||
# These `describe` and `it` blocks mirror the structure of the ::state object.
|
||||
# Please maintain this structure when adding specs for new state fields.
|
||||
describe "::getState()", ->
|
||||
@ -523,14 +523,12 @@ describe "TextEditorPresenter", ->
|
||||
expectStateUpdate presenter, -> presenter.setScrollLeft(70)
|
||||
expectValues presenter.getState().hiddenInput, {top: 0, left: 0}
|
||||
|
||||
global.enableLogs = true
|
||||
expectStateUpdate presenter, -> editor.setCursorBufferPosition([11, 43])
|
||||
expectValues presenter.getState().hiddenInput, {top: 11 * 10 - editor.getScrollTop(), left: 43 * 10 - editor.getScrollLeft()}
|
||||
global.enableLogs = false
|
||||
expectValues presenter.getState().hiddenInput, {top: 11 * 10 - presenter.getScrollTop(), left: 43 * 10 - presenter.getScrollLeft()}
|
||||
|
||||
newCursor = null
|
||||
expectStateUpdate presenter, -> newCursor = editor.addCursorAtBufferPosition([6, 10])
|
||||
expectValues presenter.getState().hiddenInput, {top: (6 * 10) - editor.getScrollTop(), left: (10 * 10) - editor.getScrollLeft()}
|
||||
expectValues presenter.getState().hiddenInput, {top: (6 * 10) - presenter.getScrollTop(), left: (10 * 10) - presenter.getScrollLeft()}
|
||||
|
||||
expectStateUpdate presenter, -> newCursor.destroy()
|
||||
expectValues presenter.getState().hiddenInput, {top: 50 - 10, left: 300 - 10}
|
||||
|
@ -54,10 +54,6 @@ class TextEditorPresenter
|
||||
@model.setWidth(@contentFrameWidth) if @contentFrameWidth?
|
||||
@model.setLineHeightInPixels(@lineHeight) if @lineHeight?
|
||||
@model.setDefaultCharWidth(@baseCharacterWidth) if @baseCharacterWidth?
|
||||
@model.setScrollTop(@scrollTop) if @scrollTop?
|
||||
@model.setScrollLeft(@scrollLeft) if @scrollLeft?
|
||||
@model.setVerticalScrollbarWidth(@measuredVerticalScrollbarWidth) if @measuredVerticalScrollbarWidth?
|
||||
@model.setHorizontalScrollbarHeight(@measuredHorizontalScrollbarHeight) if @measuredHorizontalScrollbarHeight?
|
||||
|
||||
# Private: Determines whether {TextEditorPresenter} is currently batching changes.
|
||||
# Returns a {Boolean}, `true` if is collecting changes, `false` if is applying them.
|
||||
@ -1538,13 +1534,11 @@ class TextEditorPresenter
|
||||
scrollLeft = Math.round(@constrainScrollLeft(@pendingScrollLeft))
|
||||
if scrollLeft isnt @scrollLeft and not Number.isNaN(scrollLeft)
|
||||
@scrollLeft = scrollLeft
|
||||
@model.setScrollLeft(scrollLeft)
|
||||
|
||||
commitPendingScrollTopPosition: ->
|
||||
scrollTop = Math.round(@constrainScrollTop(@pendingScrollTop))
|
||||
if scrollTop isnt @scrollTop and not Number.isNaN(scrollTop)
|
||||
@scrollTop = scrollTop
|
||||
@model.setScrollTop(scrollTop)
|
||||
|
||||
updateScrollPosition: ->
|
||||
@commitPendingLogicalScrollPosition() if @pendingScrollLogicalPosition?
|
||||
|
Loading…
Reference in New Issue
Block a user