mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Calling collapseAllPaths creates elements for every Dom node
This commit is contained in:
committed by
probablycorey
parent
10f405f61f
commit
4702f3775d
@@ -30,6 +30,7 @@ class PreviewList extends ScrollView
|
||||
@children().each (index, element) -> $(element).view().expand()
|
||||
|
||||
collapseAllPaths: ->
|
||||
@renderOperations(renderAll: true)
|
||||
@children().each (index, element) -> $(element).view().collapse()
|
||||
|
||||
destroy: ->
|
||||
@@ -46,15 +47,17 @@ class PreviewList extends ScrollView
|
||||
|
||||
@show()
|
||||
@renderOperations()
|
||||
|
||||
@find('.operation:first').addClass('selected')
|
||||
|
||||
renderOperations: ->
|
||||
renderOperations: ({renderAll}={}) ->
|
||||
renderAll ?= false
|
||||
startingScrollHeight = @prop('scrollHeight')
|
||||
for operation in @operations[@lastRenderedOperationIndex..]
|
||||
pathView = @pathViewForPath(operation.getPath())
|
||||
pathView.addOperation(operation)
|
||||
@lastRenderedOperationIndex++
|
||||
break if @prop('scrollHeight') >= startingScrollHeight + @pixelOverdraw and @prop('scrollHeight') > @height() + @pixelOverdraw
|
||||
break if not renderAll and @prop('scrollHeight') >= startingScrollHeight + @pixelOverdraw and @prop('scrollHeight') > @height() + @pixelOverdraw
|
||||
|
||||
pathViewForPath: (path) ->
|
||||
pathView = @viewsForPath[path]
|
||||
|
||||
@@ -32,3 +32,14 @@ describe "Preview List", ->
|
||||
previewList.trigger('scroll') # Not sure why scroll event isn't being triggered on it's own
|
||||
expect(previewList.prop('scrollHeight')).toBeGreaterThan previousScrollHeight
|
||||
expect(previewList.find("li").length).toBeGreaterThan previousOperationCount
|
||||
|
||||
it "renders all operations if the preview items are collapsed", ->
|
||||
waitsForPromise ->
|
||||
commandPanelView.execute('X x/so/')
|
||||
|
||||
runs ->
|
||||
expect(previewList.prop('scrollHeight')).toBeGreaterThan previewList.height()
|
||||
previousScrollHeight = previewList.prop('scrollHeight')
|
||||
previousOperationCount = previewList.find("li").length
|
||||
previewList.collapseAllPaths()
|
||||
expect(previewList.find("li").length).toBeGreaterThan previousOperationCount
|
||||
|
||||
Reference in New Issue
Block a user