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 1 commit
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/htmlContent/findreplace-bar.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div id="find-group"><!--
--><div class="search-input-container"><input type="text" id="find-what" placeholder="{{CMD_FIND_FIELD_PLACEHOLDER}}" /><div class="error"></div><span id="find-counter"></span></div><!--
-->{{^replace}}<button id="find-show-list" class="btn no-focus" tabindex="-1" title="{{FIND_SHOW_IN_A_LIST}}"><div class="button-icon"></div></button>{{/replace}}<!--
--><button id="find-case-sensitive" class="btn no-focus" tabindex="-1" title="{{BUTTON_CASESENSITIVE_HINT}}"><div class="button-icon"></div></button><!--
--><button id="find-regexp" class="btn no-focus" tabindex="-1" title="{{BUTTON_REGEXP_HINT}}"><div class="button-icon"></div></button><!--
--><div class="navigator"><!--
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 @@ -131,6 +131,7 @@ define({
"FIND_RESULT_COUNT" : "{0} results",
"FIND_RESULT_COUNT_SINGLE" : "1 result",
"FIND_NO_RESULTS" : "No results",
"FIND_SHOW_IN_A_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 @@ -858,9 +858,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
Copy link
Contributor

Choose a reason for hiding this comment

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

  • The indentation is wrong in this line.
  • No need to add a - between name and description
  • It should be just {string=} which is the same as {?string} but makes it an optional parameter, only when is the last one or the next one is optional too. Same with {Entry=}

*/
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 @@ -892,17 +893,25 @@ define(function (require, exports, module) {
currentQueryExpr = null;
currentScope = scope;
maxHitsFoundInFile = false;

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here with dash and optional parameter

*/
function _doFindInSubtree() {
var selectedEntry = ProjectManager.getSelectedItem();
_doFindInFiles(selectedEntry);
function _doFindInSubtree(scope, query) {
scope = scope || ProjectManager.getSelectedItem();
query = query || undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no need for this line, since query is optional for _doFindInFiles.

_doFindInFiles(scope, query);
}


Expand Down
9 changes: 8 additions & 1 deletion src/search/FindReplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,11 @@ define(function (require, exports, module) {
// 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());

// Buttons disabled if blank, OR if no matches (Replace buttons) / < 2 matches (nav buttons)
// Buttons disabled if blank, OR if no matches (Replace buttons, Show in list button) /
// < 2 matches (nav buttons)
$("#find-prev, #find-next").prop("disabled", !state.foundAny || numResults < 2);
$("#replace-yes, #replace-all").prop("disabled", !state.foundAny);
$("#find-show-list").prop("disabled", !state.foundAny);
}

cm.operation(function () {
Expand Down Expand Up @@ -413,6 +415,11 @@ define(function (require, exports, module) {

handleQueryChange(editor, state);
})
.on("click", "#find-show-list", function (e) {
var query = $("#find-what").val();
modalBar.close(true, true);
CommandManager.execute(Commands.EDIT_FIND_IN_SUBTREE, DocumentManager.getCurrentDocument().file, query);
})
.on("keydown", function (e) {
if (e.keyCode === KeyEvent.DOM_VK_RETURN) {
if (!e.shiftKey) {
Expand Down
10 changes: 8 additions & 2 deletions src/styles/brackets.less
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ a, img {
display: inline-block;
}

#find-case-sensitive, #find-regexp {
#find-case-sensitive, #find-regexp, #find-show-list {
padding: 1px 5px;
}
.button-icon { // icons must be nested inside button so we can apply padding w/o tiling icon
Expand All @@ -1123,6 +1123,9 @@ a, img {
#find-case-sensitive.active .button-icon {
.sprite-swap(0, 72px);
}
#find-show-list .button-icon {
.sprite-swap(0, 96px);
}
#find-regexp.active, #find-case-sensitive.active {
background-color: @tc-highlight;
}
Expand All @@ -1144,6 +1147,9 @@ a, img {
border-right: none;
margin-right: 0;
}
#find-show-list {
margin-right: 0;
}
#find-next, #replace-all, #find-regexp {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
Expand All @@ -1157,7 +1163,7 @@ a, img {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
#find-case-sensitive, #replace-yes {
#find-case-sensitive, #replace-yes, #find-show-list {
border-left: none;
margin-left: 0px;
border-radius: 0;
Expand Down
2 changes: 1 addition & 1 deletion src/styles/images/find-replace-sprites.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.