diff --git a/src/htmlContent/search-results.html b/src/htmlContent/search-results.html
index 010c14c94ed..56cb3fd8122 100644
--- a/src/htmlContent/search-results.html
+++ b/src/htmlContent/search-results.html
@@ -2,7 +2,10 @@
{{#searchList}}
- {{{filename}}} |
+
+
+ {{{filename}}}
+ |
{{#items}}
diff --git a/src/nls/root/strings.js b/src/nls/root/strings.js
index 9b4b8d778ae..4c83484c04a 100644
--- a/src/nls/root/strings.js
+++ b/src/nls/root/strings.js
@@ -163,6 +163,7 @@ define({
"FIND_IN_FILES_MORE_THAN" : "Over ",
"FIND_IN_FILES_PAGING" : "{0}—{1}",
"FIND_IN_FILES_FILE_PATH" : "{0} {2} {1}", // We shoudl use normal dashes on Windows instead of em dash eventually
+ "FIND_IN_FILES_EXPAND_COLLAPSE" : "Ctrl/Cmd click to expand/collapse all",
"ERROR_FETCHING_UPDATE_INFO_TITLE" : "Error getting update info",
"ERROR_FETCHING_UPDATE_INFO_MSG" : "There was a problem getting the latest update information from the server. Please make sure you are connected to the internet and try again.",
diff --git a/src/search/FindInFiles.js b/src/search/FindInFiles.js
index 7b6aec57046..074c51de9bb 100644
--- a/src/search/FindInFiles.js
+++ b/src/search/FindInFiles.js
@@ -417,7 +417,7 @@ define(function (require, exports, module) {
// Insert the search results
$searchContent
.empty()
- .append(Mustache.render(searchResultsTemplate, {searchList: searchList}))
+ .append(Mustache.render(searchResultsTemplate, {searchList: searchList, Strings: Strings}))
.scrollTop(0) // Otherwise scroll pos from previous contents is remembered
.off(".searchList") // Remove the old events
@@ -437,14 +437,33 @@ define(function (require, exports, module) {
// This is a file title row, expand/collapse on click
if ($row.hasClass("file-section")) {
- // Clicking the file section header collapses/expands result rows for that file
- $row.nextUntil(".file-section").toggle();
+ var $titleRows,
+ collapsed = !searchResults[fullPath].collapsed;
- var $triangle = $(".disclosure-triangle", $row);
- $triangle.toggleClass("expanded").toggleClass("collapsed");
+ if (e.metaKey || e.ctrlKey) { //Expand all / Collapse all
+ $titleRows = $(e.target).closest("table").find(".file-section");
+ } else {
+ // Clicking the file section header collapses/expands result rows for that file
+ $titleRows = $row;
+ }
- searchResults[fullPath].collapsed = !searchResults[fullPath].collapsed;
-
+ $titleRows.each(function () {
+ fullPath = searchList[$(this).data("file")].fullPath;
+ searchItem = searchResults[fullPath];
+
+ if (searchItem.collapsed !== collapsed) {
+ searchItem.collapsed = collapsed;
+ $(this).nextUntil(".file-section").toggle();
+ $(this).find(".disclosure-triangle").toggleClass("expanded").toggleClass("collapsed");
+ }
+ });
+
+ //In Expand/Collapse all, reset all search results 'collapsed' flag to same value(true/false).
+ if (e.metaKey || e.ctrlKey) {
+ _.forEach(searchResults, function (item) {
+ item.collapsed = collapsed;
+ });
+ }
// This is a file row, show the result on click
} else {
// Grab the required item data