mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 15:37:46 +03:00
WIP: Don't allow impossibly high scroll top values.
It fixes the move to bottom issues, but breaks some other tests. Not sure why yet...
This commit is contained in:
parent
3c2facc7be
commit
9cfbce826d
@ -8,7 +8,7 @@ $ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
fs = require 'fs'
|
||||
|
||||
describe "Editor", ->
|
||||
fdescribe "Editor", ->
|
||||
[rootView, buffer, editor, cachedLineHeight] = []
|
||||
|
||||
getLineHeight = ->
|
||||
@ -72,7 +72,7 @@ describe "Editor", ->
|
||||
newEditor.width(editor.width())
|
||||
rootView.remove()
|
||||
newEditor.attachToDom()
|
||||
expect(newEditor.scrollTop()).toBe 1.5 * editor.lineHeight
|
||||
expect(newEditor.scrollTop()).toBe editor.scrollTop()
|
||||
expect(newEditor.scrollView.scrollLeft()).toBe 44
|
||||
|
||||
describe ".setBuffer(buffer)", ->
|
||||
@ -701,7 +701,8 @@ describe "Editor", ->
|
||||
expect(editor.renderedLines.find('.line').text()).toBe buffer.lineForRow(0)
|
||||
|
||||
describe "when autoscrolling at the end of the document", ->
|
||||
xit "renders lines properly", ->
|
||||
it "renders lines properly", ->
|
||||
console.log editor.lineOverdraw
|
||||
editor.setBuffer(new Buffer(require.resolve 'fixtures/two-hundred.txt'))
|
||||
editor.attachToDom(heightInLines: 5.5)
|
||||
expect(editor.renderedLines.find('.line').length).toBe 8
|
||||
|
@ -273,7 +273,9 @@ class Editor extends View
|
||||
scrollTop: (scrollTop, options) ->
|
||||
return @cachedScrollTop or 0 unless scrollTop?
|
||||
|
||||
scrollTop = Math.max(0, scrollTop)
|
||||
maxScrollTop = @scrollView.prop('scrollHeight') - @scrollView.height()
|
||||
scrollTop = Math.floor(Math.min(maxScrollTop, Math.max(0, scrollTop)))
|
||||
|
||||
return if scrollTop == @cachedScrollTop
|
||||
@cachedScrollTop = scrollTop
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user