Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/htmlContent/search-results.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
<tbody>
{{#searchList}}
<tr class="file-section" data-file="{{file}}">
<td colspan="2"><span class="disclosure-triangle expanded"></span>{{{filename}}}</td>
<td colspan="2">
<span class="disclosure-triangle expanded" title="{{Strings.FIND_IN_FILES_EXPAND_COLLAPSE}}"></span>
{{{filename}}}
</td>
</tr>
{{#items}}
<tr data-file="{{file}}" data-item="{{item}}">
Expand Down
1 change: 1 addition & 0 deletions src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ define({
"FIND_IN_FILES_MORE_THAN" : "Over ",
"FIND_IN_FILES_PAGING" : "{0}&mdash;{1}",
"FIND_IN_FILES_FILE_PATH" : "<span class='dialog-filename'>{0}</span> {2} <span class='dialog-path'>{1}</span>", // 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.",

Expand Down
33 changes: 26 additions & 7 deletions src/search/FindInFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have a comment here to mention that this is required to collapse/uncollapse all the files and not just the ones in the current page.

item.collapsed = collapsed;
});
}
// This is a file row, show the result on click
} else {
// Grab the required item data
Expand Down