diff --git a/src/nls/root/strings.js b/src/nls/root/strings.js index 6d27096eb19..fe3748288f0 100644 --- a/src/nls/root/strings.js +++ b/src/nls/root/strings.js @@ -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", diff --git a/src/search/FindInFiles.js b/src/search/FindInFiles.js index 7021995d52d..0690e5a2546 100644 --- a/src/search/FindInFiles.js +++ b/src/search/FindInFiles.js @@ -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)) { @@ -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); } diff --git a/src/search/FindReplace.js b/src/search/FindReplace.js index 4cfb8cca485..0602803c30f 100644 --- a/src/search/FindReplace.js +++ b/src/search/FindReplace.js @@ -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); @@ -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, @@ -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); diff --git a/src/styles/brackets.less b/src/styles/brackets.less index 41ae3cc550c..4f502992a5a 100644 --- a/src/styles/brackets.less +++ b/src/styles/brackets.less @@ -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; } }