Fix issues with collapsing search results
MODIFY
lib/project/results-view.js
lib/project/results-view.js
@@ -67,6 +67,7 @@ class ResultsView {
didClearSearchState() {
this.selectedResultIndex = 0;
this.selectedMatchIndex = 0;
+ this.collapsedResultIndices.length = 0;
etch.update(this);
}
@@ -347,9 +348,9 @@ class ResultsView {
}
expandResult() {
- if (this.selectedResultIndex !== -1 && this.selectedMatchIndex == -1) {
+ if (this.selectedResultIndex !== -1) {
this.collapsedResultIndices[this.selectedResultIndex] = false;
- this.selectedMatchIndex = 0;
+ if (this.selectedMatchIndex === -1) this.selectedMatchIndex = 0;
etch.update(this);
}
}

MODIFY
spec/results-view-spec.js
spec/results-view-spec.js
@@ -284,6 +284,22 @@ describe('ResultsView', () => {
resultsView.expandAllResults();
expect(resultsView.element.querySelector('.selected')).toBe(selectedPath);
});
+
+ it('re-expands all results when running a new search', async () => {
+ projectFindView.findEditor.setText('items');
+ atom.commands.dispatch(projectFindView.element, 'core:confirm');
+ await searchPromise;
+
+ resultsView = getResultsView();
+ resultsView.collapseResult();
+ expect(resultsView.element.querySelector('.collapsed')).not.toBe(null);
+
+ projectFindView.findEditor.setText('sort');
+ atom.commands.dispatch(projectFindView.element, 'core:confirm');
+ await searchPromise;
+
+ expect(resultsView.element.querySelector('.collapsed')).toBe(null);
+ })
});
describe("opening results", () => {

Fix issues with collapsing search results