mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
Merge branch 'master' of github.com:github/atom
This commit is contained in:
@@ -292,6 +292,25 @@ describe "Editor", ->
|
||||
editor.loadNextEditSession()
|
||||
expect(editor.buffer.path).toBe "2"
|
||||
|
||||
it "restores scroll postion of edit session", ->
|
||||
editor.attachToDom(heightInLines: 12)
|
||||
buffer1 = editor.buffer
|
||||
firstScrollTop = editor.scrollTop()
|
||||
|
||||
buffer2 = new Buffer(require.resolve('fixtures/two-hundred.txt'))
|
||||
editor.setBuffer(buffer2)
|
||||
editor.moveCursorToBottom()
|
||||
secondScrollTop = editor.scrollTop()
|
||||
|
||||
expect(firstScrollTop).not.toEqual secondScrollTop
|
||||
editor.loadNextEditSession()
|
||||
expect(editor.buffer.path).toBe buffer1.path
|
||||
expect(editor.scrollTop()).toBe firstScrollTop
|
||||
|
||||
editor.loadNextEditSession()
|
||||
expect(editor.buffer.path).toBe buffer2.path
|
||||
expect(editor.scrollTop()).toBe secondScrollTop
|
||||
|
||||
describe ".loadPreviousEditSession()", ->
|
||||
it "loads the next editor state and wraps to beginning when end is reached", ->
|
||||
buffer0 = new Buffer("0")
|
||||
@@ -313,19 +332,19 @@ describe "Editor", ->
|
||||
beforeEach ->
|
||||
editor.attachToDom(heightInLines: 5)
|
||||
expect(editor.verticalScrollbar.scrollTop()).toBe 0
|
||||
expect(editor.renderedLines.css('-webkit-tranform')).toBeNull()
|
||||
expect(editor.gutter.lineNumbers.css('-webkit-tranform')).toBeNull()
|
||||
|
||||
describe "when called with a scroll top argument", ->
|
||||
it "sets the scrollTop of the vertical scrollbar and sets scrollTop on the line numbers and lines", ->
|
||||
editor.scrollTop(100)
|
||||
expect(editor.verticalScrollbar.scrollTop()).toBe 100
|
||||
expect(editor.scrollView.scrollTop()).toBe 100
|
||||
expect(editor.scrollView.scrollTop()).toBe 0
|
||||
expect(editor.renderedLines.css('top')).toBe "-100px"
|
||||
expect(editor.gutter.scrollTop()).toBe 100
|
||||
|
||||
editor.scrollTop(120)
|
||||
expect(editor.verticalScrollbar.scrollTop()).toBe 120
|
||||
expect(editor.scrollView.scrollTop()).toBe 120
|
||||
expect(editor.scrollView.scrollTop()).toBe 0
|
||||
expect(editor.renderedLines.css('top')).toBe "-120px"
|
||||
expect(editor.gutter.scrollTop()).toBe 120
|
||||
|
||||
it "does not allow negative scrollTops to be assigned", ->
|
||||
@@ -347,7 +366,7 @@ describe "Editor", ->
|
||||
it "doesn't adjust the scrollTop of the vertical scrollbar", ->
|
||||
editor.scrollTop(100, adjustVerticalScrollbar: false)
|
||||
expect(editor.verticalScrollbar.scrollTop()).toBe 0
|
||||
expect(editor.scrollView.scrollTop()).toBe 100
|
||||
expect(editor.renderedLines.css('top')).toBe "-100px"
|
||||
expect(editor.gutter.scrollTop()).toBe 100
|
||||
|
||||
describe "when called with no argument", ->
|
||||
@@ -1035,7 +1054,7 @@ describe "Editor", ->
|
||||
expect(editor.scrollTop()).toBe(editor.lineHeight)
|
||||
|
||||
editor.moveCursorUp()
|
||||
expect(editor.scrollView.scrollTop()).toBe(0)
|
||||
expect(editor.renderedLines.css('top')).toBe "0px"
|
||||
|
||||
describe "horizontal scrolling", ->
|
||||
charWidth = null
|
||||
|
||||
@@ -284,7 +284,7 @@ class Editor extends View
|
||||
scrollTop: (scrollTop, options) ->
|
||||
return @cachedScrollTop or 0 unless scrollTop?
|
||||
|
||||
maxScrollTop = @scrollView.prop('scrollHeight') - @scrollView.height()
|
||||
maxScrollTop = @verticalScrollbar.prop('scrollHeight') - @verticalScrollbar.height()
|
||||
scrollTop = Math.floor(Math.min(maxScrollTop, Math.max(0, scrollTop)))
|
||||
|
||||
return if scrollTop == @cachedScrollTop
|
||||
@@ -292,7 +292,7 @@ class Editor extends View
|
||||
|
||||
@updateRenderedLines() if @attached
|
||||
|
||||
@scrollView.scrollTop(scrollTop)
|
||||
@renderedLines.css('top', -scrollTop)
|
||||
@gutter.scrollTop(scrollTop)
|
||||
if options?.adjustVerticalScrollbar ? true
|
||||
@verticalScrollbar.scrollTop(scrollTop)
|
||||
|
||||
@@ -108,10 +108,9 @@ class Autocomplete extends View
|
||||
@currentMatchBufferRange = null
|
||||
@allMatches = @findMatchesForCurrentSelection()
|
||||
|
||||
|
||||
originalCursorPosition = @editor.getCursorScreenPosition()
|
||||
@filterMatches()
|
||||
@editor.renderedLines.append(this)
|
||||
@editor.append(this)
|
||||
@setPosition(originalCursorPosition)
|
||||
|
||||
@miniEditor.focus()
|
||||
@@ -126,11 +125,12 @@ class Autocomplete extends View
|
||||
setPosition: (originalCursorPosition) ->
|
||||
{ left, top } = @editor.pixelPositionForScreenPosition(originalCursorPosition)
|
||||
|
||||
top -= @editor.scrollTop()
|
||||
potentialTop = top + @editor.lineHeight
|
||||
potentialBottom = potentialTop + @outerHeight()
|
||||
|
||||
if potentialBottom > @editor.scrollBottom()
|
||||
@css(left: left, bottom: @editor.renderedLines.outerHeight() - top, top: 'inherit')
|
||||
if potentialBottom > @editor.outerHeight()
|
||||
@css(left: left, bottom: @editor.outerHeight() - top, top: 'inherit')
|
||||
else
|
||||
@css(left: left, top: potentialTop, bottom: 'inherit')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user