mirror of
https://github.com/atom/atom.git
synced 2026-02-16 01:25:13 -05:00
Properly append and count matches
This commit is contained in:
@@ -177,7 +177,6 @@ class Project
|
||||
for [column, length] in matchPositions
|
||||
range = new Range([row, column], [row, column + length])
|
||||
match = lineText.substr(column, length)
|
||||
console.log(path)
|
||||
iterator({path, range, match})
|
||||
|
||||
deferred = $.Deferred()
|
||||
|
||||
@@ -119,6 +119,7 @@ class CommandPanelView extends View
|
||||
@previewHeader.show()
|
||||
@searchLoadingMessage.show()
|
||||
@errorMessages.empty()
|
||||
project.previewList = @previewList
|
||||
|
||||
try
|
||||
@commandInterpreter.eval(command, rootView.getActivePaneItem()).done ({operationsToPreview, errorMessages}) =>
|
||||
@@ -133,7 +134,7 @@ class CommandPanelView extends View
|
||||
@li errorMessage for errorMessage in errorMessages
|
||||
else if operationsToPreview?.length
|
||||
@previewList.focus()
|
||||
@previewCount.text("#{_.pluralize(operationsToPreview.length, 'match', 'matches')} in #{_.pluralize(@previewList.getPathCount(), 'file')}").show()
|
||||
@previewCount.text("#{_.pluralize(operationsToPreview.length, 'match', 'matches')} in #{_.pluralize(@previewList.getPathCount(operationsToPreview), 'file')}").show()
|
||||
else
|
||||
@detach()
|
||||
catch error
|
||||
|
||||
@@ -14,11 +14,13 @@ class SelectAllMatchesInProject extends Command
|
||||
deferred = $.Deferred()
|
||||
operations = []
|
||||
promise = project.scan @regex, ({path, range}) ->
|
||||
operations.push(new Operation(
|
||||
op = new Operation(
|
||||
project: project
|
||||
path: path
|
||||
bufferRange: range
|
||||
))
|
||||
)
|
||||
project.previewList.populateSingle(op)
|
||||
operations.push(op)
|
||||
|
||||
promise.done -> deferred.resolve(operations)
|
||||
deferred.promise()
|
||||
|
||||
@@ -39,7 +39,6 @@ class PreviewList extends ScrollView
|
||||
hasOperations: -> @operations?
|
||||
|
||||
populate: (operations) ->
|
||||
debugger;
|
||||
@destroyOperations() if @operations
|
||||
@operations = operations
|
||||
@lastRenderedOperationIndex = 0
|
||||
@@ -51,6 +50,14 @@ class PreviewList extends ScrollView
|
||||
|
||||
@find('.operation:first').addClass('selected')
|
||||
|
||||
populateSingle: (operation) ->
|
||||
@viewsForPath = {}
|
||||
|
||||
@show()
|
||||
@renderOperation(operation)
|
||||
|
||||
@find('.operation:first').addClass('selected')
|
||||
|
||||
renderOperations: ({renderAll}={}) ->
|
||||
renderAll ?= false
|
||||
startingScrollHeight = @prop('scrollHeight')
|
||||
@@ -60,6 +67,13 @@ class PreviewList extends ScrollView
|
||||
@lastRenderedOperationIndex++
|
||||
break if not renderAll and @prop('scrollHeight') >= startingScrollHeight + @pixelOverdraw and @prop('scrollHeight') > @height() + @pixelOverdraw
|
||||
|
||||
renderOperation: (operation, {renderAll}={}) ->
|
||||
renderAll ?= false
|
||||
startingScrollHeight = @prop('scrollHeight')
|
||||
pathView = @pathViewForPath(operation.getPath())
|
||||
pathView.addOperation(operation)
|
||||
|
||||
|
||||
pathViewForPath: (path) ->
|
||||
pathView = @viewsForPath[path]
|
||||
if not pathView
|
||||
@@ -97,8 +111,8 @@ class PreviewList extends ScrollView
|
||||
previousView.addClass('selected')
|
||||
previousView.scrollTo()
|
||||
|
||||
getPathCount: ->
|
||||
_.keys(_.groupBy(@operations, (operation) -> operation.getPath())).length
|
||||
getPathCount: (operations=@operations)->
|
||||
_.keys(_.groupBy(operations, (operation) -> operation.getPath())).length
|
||||
|
||||
getOperations: ->
|
||||
new Array(@operations...)
|
||||
|
||||
Reference in New Issue
Block a user