diff --git a/src/app/project.coffee b/src/app/project.coffee index a70c548ff..a3da8a483 100644 --- a/src/app/project.coffee +++ b/src/app/project.coffee @@ -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() diff --git a/src/packages/command-panel/lib/command-panel-view.coffee b/src/packages/command-panel/lib/command-panel-view.coffee index 980df48a5..bd72f93ee 100644 --- a/src/packages/command-panel/lib/command-panel-view.coffee +++ b/src/packages/command-panel/lib/command-panel-view.coffee @@ -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 diff --git a/src/packages/command-panel/lib/commands/select-all-matches-in-project.coffee b/src/packages/command-panel/lib/commands/select-all-matches-in-project.coffee index c9255a4fc..155d792cf 100644 --- a/src/packages/command-panel/lib/commands/select-all-matches-in-project.coffee +++ b/src/packages/command-panel/lib/commands/select-all-matches-in-project.coffee @@ -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() diff --git a/src/packages/command-panel/lib/preview-list.coffee b/src/packages/command-panel/lib/preview-list.coffee index 0f7bea1d3..8569868fd 100644 --- a/src/packages/command-panel/lib/preview-list.coffee +++ b/src/packages/command-panel/lib/preview-list.coffee @@ -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...)