Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

For #6093: Added button to show all results in a list #6099

Closed
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
1 change: 1 addition & 0 deletions src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ define({
"FIND_RESULT_COUNT" : "{0} results",
"FIND_RESULT_COUNT_SINGLE" : "1 result",
"FIND_NO_RESULTS" : "No results",
"FIND_SHOW_IN_LIST" : "Show results in a list",
"REPLACE_PLACEHOLDER" : "Replace with\u2026",
"BUTTON_REPLACE_ALL" : "All\u2026",
"BUTTON_REPLACE" : "Replace",
Expand Down
25 changes: 17 additions & 8 deletions src/search/FindInFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -980,9 +980,10 @@ define(function (require, exports, module) {
* @private
* Displays a non-modal embedded dialog above the code mirror editor that allows the user to do
* a find operation across all files in the project.
* @param {?Entry} scope Project file/subfolder to search within; else searches whole project.
* @param {Entry=} scope Project file/subfolder to search within; else searches whole project.
* @param {string=} query The query to search for; else asks for the query
*/
function _doFindInFiles(scope) {
function _doFindInFiles(scope, query) {
// If the scope is a file with a custom viewer, then we
// don't show find in files dialog.
if (scope && EditorManager.getCustomViewerForPath(scope.fullPath)) {
Expand Down Expand Up @@ -1020,18 +1021,26 @@ define(function (require, exports, module) {
currentQueryExpr = null;
currentScope = scope;
maxHitsFoundInFile = false;

exports._searchResults = null; // for unit tests

dialog.showDialog(initialString, scope);

if (query) {
StatusBar.showBusyIndicator(true);
dialog.closed = true;
_doSearch(query);
} else {
dialog.showDialog(initialString, scope);
}
}

/**
* @private
* Search within the file/subtree defined by the sidebar selection
* @param {Entry=} scope Project file/subfolder to search within; else takes entry selected in file tree.
* @param {string=} query The query to search for; else asks for the query
*/
function _doFindInSubtree() {
var selectedEntry = ProjectManager.getSelectedItem();
_doFindInFiles(selectedEntry);
function _doFindInSubtree(scope, query) {
scope = scope || ProjectManager.getSelectedItem();
_doFindInFiles(scope, query);
}


Expand Down
22 changes: 20 additions & 2 deletions src/search/FindReplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,11 @@ define(function (require, exports, module) {

function indicateHasMatches(numResults) {
// Make the field red if it's not blank and it has no matches (which also covers invalid regexes)
ViewUtils.toggleClass($("#find-what"), "no-results", !state.foundAny && $("#find-what").val());
var query = $("#find-what").val(),
showInListTitle = Strings.FIND_SHOW_IN_LIST + " (" + KeyBindingManager.formatKeyDescriptor("Alt-Enter") + ")";

ViewUtils.toggleClass($("#find-what, #find-counter"), "no-results", !state.foundAny && query);
$("#find-counter").attr("title", (state.foundAny && query) ? showInListTitle : "");

// Buttons disabled if blank, OR if no matches (Replace buttons) / < 2 matches (nav buttons)
$("#find-prev, #find-next").prop("disabled", !state.foundAny || numResults < 2);
Expand Down Expand Up @@ -360,6 +364,17 @@ define(function (require, exports, module) {
}
}

/**
* Shows the found results in a list (which is just the invoked FindInFiles panel)
*/
function _showResultsInList() {
if (!$("#find-counter").hasClass("no-results")) {
var query = $("#find-what").val();
modalBar.close(true, true);
CommandManager.execute(Commands.EDIT_FIND_IN_SUBTREE, DocumentManager.getCurrentDocument().file, query);
}
}


/**
* Opens the search bar with the given HTML content (Find or Find-Replace), attaches common Find behaviors,
Expand Down Expand Up @@ -413,9 +428,12 @@ define(function (require, exports, module) {

handleQueryChange(editor, state);
})
.on("click", "#find-counter", _showResultsInList)
.on("keydown", function (e) {
if (e.keyCode === KeyEvent.DOM_VK_RETURN) {
if (!e.shiftKey) {
if (e.altKey) {
_showResultsInList();
} else if (!e.shiftKey) {
findNext(editor);
} else {
findNext(editor, true);
Expand Down
8 changes: 7 additions & 1 deletion src/styles/brackets.less
Original file line number Diff line number Diff line change
Expand Up @@ -1112,10 +1112,16 @@ a, img {
}
#find-counter {
position: absolute;
color: @tc-light-weight-quiet-text;
color: @tc-call-to-action;
top: 1px;
right: 2px;
font-size: 12px;
cursor: pointer;
}

#find-counter.no-results {
color: @tc-light-weight-quiet-text;
cursor: default;
}
}

Expand Down