mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-11 04:48:44 +03:00
Don't count DOM elements for operations count
The number of DOM elements rendered is fluid and using this number displays inaccurate results as new operations are rendered. Instead just set the operation count when creating the PathView based on considering all the operations available. Closes #502
This commit is contained in:
parent
946f908ab7
commit
09967db742
@ -14,7 +14,7 @@ class PathView extends View
|
||||
@span outlet: 'description', class: 'path-match-number'
|
||||
@ul outlet: 'matches', class: 'matches', =>
|
||||
|
||||
initialize: ({@previewList}) ->
|
||||
initialize: ({@previewList, operationCount}) ->
|
||||
@pathDetails.on 'mousedown', => @toggle(true)
|
||||
@subscribe @previewList, 'command-panel:collapse-result', =>
|
||||
if @isSelected()
|
||||
@ -27,9 +27,10 @@ class PathView extends View
|
||||
@toggle(true)
|
||||
false
|
||||
|
||||
@description.text("(#{operationCount})")
|
||||
|
||||
addOperation: (operation) ->
|
||||
@matches.append new OperationView({operation, @previewList})
|
||||
@description.text("(#{@matches.find('li').length})")
|
||||
|
||||
isSelected: ->
|
||||
@hasClass('selected') or @find('.selected').length
|
||||
|
@ -60,7 +60,7 @@ class PreviewList extends ScrollView
|
||||
pathViewForPath: (path) ->
|
||||
pathView = @viewsForPath[path]
|
||||
if not pathView
|
||||
pathView = new PathView({path: path, previewList: this})
|
||||
pathView = new PathView({path: path, previewList: this, operationCount: @getPathOperationCount(path)})
|
||||
@viewsForPath[path] = pathView
|
||||
@append(pathView)
|
||||
pathView
|
||||
@ -97,6 +97,9 @@ class PreviewList extends ScrollView
|
||||
getPathCount: ->
|
||||
_.keys(_.groupBy(@operations, (operation) -> operation.getPath())).length
|
||||
|
||||
getPathOperationCount: (path) ->
|
||||
@operations.filter((operation) -> path is operation.getPath()).length
|
||||
|
||||
getOperations: ->
|
||||
new Array(@operations...)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user