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

[PM] Lots of Find in Files improvements #3151

Closed
wants to merge 1 commit into from
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
84 changes: 51 additions & 33 deletions src/base-config/keyboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,39 +59,6 @@
"platform": "mac"
}
],
"edit.find": [
"Ctrl-F"
],
"edit.findInFiles": [
"Ctrl-Shift-F"
],
"edit.findNext": [
{
"key": "F3"
},
{
"key": "Cmd-G",
"platform": "mac"
}
],
"edit.findPrevious": [
{
"key": "Shift-F3"
},
{
"key": "Cmd-Shift-G",
"platform": "mac"
}
],
"edit.replace": [
{
"key": "Ctrl-H"
},
{
"key": "Cmd-Alt-F",
"platform": "mac"
}
],
"edit.indent": [
{
"key": "Ctrl-]"
Expand Down Expand Up @@ -142,6 +109,57 @@
"platform": "mac"
}
],
"search.find": [
"Ctrl-F"
],
"search.findNext": [
{
"key": "F3"
},
{
"key": "Cmd-G",
"platform": "mac"
}
],
"search.findPrevious": [
{
"key": "Shift-F3"
},
{
"key": "Cmd-Shift-G",
"platform": "mac"
}
],
"search.replace": [
{
"key": "Ctrl-H"
},
{
"key": "Cmd-Alt-F",
"platform": "mac"
}
],
"search.findInFiles": [
"Ctrl-Shift-F"
],
"search.nextResult": [
{
"key": "F4"
},
{
"key": "Cmd-J",
"platform": "mac"
}
],
"search.previousResult": [
{
"key": "Shift-F4"
},
{
"key": "Cmd-Shift-J",
"platform": "mac"
}
],
"view.hideSidebar": [
"Ctrl-Shift-H"
],
Expand Down
17 changes: 11 additions & 6 deletions src/command/Commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ define(function (require, exports, module) {
exports.EDIT_PASTE = "edit.paste";
exports.EDIT_SELECT_ALL = "edit.selectAll";
exports.EDIT_SELECT_LINE = "edit.selectLine";
exports.EDIT_FIND = "edit.find";
exports.EDIT_FIND_IN_FILES = "edit.findInFiles";
exports.EDIT_FIND_IN_SUBTREE = "edit.findInSubtree";
exports.EDIT_FIND_NEXT = "edit.findNext";
exports.EDIT_FIND_PREVIOUS = "edit.findPrevious";
exports.EDIT_REPLACE = "edit.replace";
exports.EDIT_INDENT = "edit.indent";
exports.EDIT_UNINDENT = "edit.unindent";
exports.EDIT_DUPLICATE = "edit.duplicate";
Expand All @@ -73,6 +67,17 @@ define(function (require, exports, module) {
exports.EDIT_LINE_DOWN = "edit.lineDown";
exports.TOGGLE_CLOSE_BRACKETS = "edit.autoCloseBrackets";

// SEARCH
exports.SEARCH_FIND = "search.find";
exports.SEARCH_FIND_NEXT = "search.findNext";
exports.SEARCH_FIND_PREVIOUS = "search.findPrevious";
exports.SEARCH_REPLACE = "search.replace";
exports.SEARCH_FIND_IN_FILES = "search.findInFiles";
exports.SEARCH_FIND_IN_SUBTREE = "search.findInSubtree";
exports.SEARCH_FIND_IN_WORKING_SET = "search.findInWorkingSet";
exports.SEARCH_NEXT_RESULT = "search.nextResult";
exports.SEARCH_PREVIOUS_RESULT = "search.previousResult";

// VIEW
exports.VIEW_HIDE_SIDEBAR = "view.hideSidebar";
exports.VIEW_INCREASE_FONT_SIZE = "view.increaseFontSize";
Expand Down
30 changes: 18 additions & 12 deletions src/command/DefaultMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,6 @@ define(function (require, exports, module) {
menu.addMenuItem(Commands.EDIT_SELECT_ALL);
menu.addMenuItem(Commands.EDIT_SELECT_LINE);
menu.addMenuDivider();
menu.addMenuItem(Commands.EDIT_FIND);
menu.addMenuItem(Commands.EDIT_FIND_IN_FILES);
menu.addMenuItem(Commands.EDIT_FIND_NEXT);

menu.addMenuItem(Commands.EDIT_FIND_PREVIOUS);

menu.addMenuDivider();
menu.addMenuItem(Commands.EDIT_REPLACE);
menu.addMenuDivider();
menu.addMenuItem(Commands.EDIT_INDENT);
menu.addMenuItem(Commands.EDIT_UNINDENT);
menu.addMenuItem(Commands.EDIT_DUPLICATE);
Expand All @@ -98,6 +89,22 @@ define(function (require, exports, module) {
menu.addMenuDivider();
menu.addMenuItem(Commands.TOGGLE_CLOSE_BRACKETS);

/*
* Search menu
*/
menu = Menus.addMenu(Strings.SEARCH_MENU, Menus.AppMenuBar.SEARCH_MENU);
menu.addMenuItem(Commands.SEARCH_FIND);
menu.addMenuItem(Commands.SEARCH_FIND_NEXT);
menu.addMenuItem(Commands.SEARCH_FIND_PREVIOUS);
menu.addMenuDivider();
menu.addMenuItem(Commands.SEARCH_REPLACE);
menu.addMenuDivider();
menu.addMenuItem(Commands.SEARCH_FIND_IN_FILES);
menu.addMenuItem(Commands.SEARCH_FIND_IN_WORKING_SET);
menu.addMenuItem(Commands.SEARCH_FIND_IN_SUBTREE);
menu.addMenuItem(Commands.SEARCH_NEXT_RESULT);
menu.addMenuItem(Commands.SEARCH_PREVIOUS_RESULT);

/*
* View menu
*/
Expand All @@ -116,7 +123,6 @@ define(function (require, exports, module) {
menu = Menus.addMenu(Strings.NAVIGATE_MENU, Menus.AppMenuBar.NAVIGATE_MENU);
menu.addMenuItem(Commands.NAVIGATE_QUICK_OPEN);
menu.addMenuItem(Commands.NAVIGATE_GOTO_LINE);

menu.addMenuItem(Commands.NAVIGATE_GOTO_DEFINITION);
menu.addMenuItem(Commands.NAVIGATE_GOTO_JSLINT_ERROR);
menu.addMenuDivider();
Expand Down Expand Up @@ -176,15 +182,15 @@ define(function (require, exports, module) {
project_cmenu.addMenuItem(Commands.FILE_NEW_FOLDER);
project_cmenu.addMenuItem(Commands.FILE_RENAME);
project_cmenu.addMenuDivider();
project_cmenu.addMenuItem(Commands.EDIT_FIND_IN_SUBTREE);
project_cmenu.addMenuItem(Commands.SEARCH_FIND_IN_SUBTREE);

var working_set_cmenu = Menus.registerContextMenu(Menus.ContextMenuIds.WORKING_SET_MENU);
working_set_cmenu.addMenuItem(Commands.FILE_CLOSE);
working_set_cmenu.addMenuItem(Commands.FILE_SAVE);
working_set_cmenu.addMenuItem(Commands.FILE_RENAME);
working_set_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_FILE_TREE);
working_set_cmenu.addMenuDivider();
working_set_cmenu.addMenuItem(Commands.EDIT_FIND_IN_SUBTREE);
working_set_cmenu.addMenuItem(Commands.SEARCH_FIND_IN_SUBTREE);
working_set_cmenu.addMenuDivider();
working_set_cmenu.addMenuItem(Commands.SORT_WORKINGSET_BY_ADDED);
working_set_cmenu.addMenuItem(Commands.SORT_WORKINGSET_BY_NAME);
Expand Down
10 changes: 8 additions & 2 deletions src/command/Menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ define(function (require, exports, module) {
var AppMenuBar = {
FILE_MENU : "file-menu",
EDIT_MENU : "edit-menu",
SEARCH_MENU : "search-menu",
VIEW_MENU : "view-menu",
NAVIGATE_MENU : "navigate-menu",
HELP_MENU : "help-menu"
Expand Down Expand Up @@ -77,10 +78,15 @@ define(function (require, exports, module) {
FILE_SAVE_COMMANDS: {sectionMarker: Commands.FILE_SAVE},
FILE_LIVE: {sectionMarker: Commands.FILE_LIVE_FILE_PREVIEW},

EDIT_UNDO_REDO_COMMANDS: {sectionMarker: Commands.EDIT_UNDO},
EDIT_TEXT_COMMANDS: {sectionMarker: Commands.EDIT_CUT},
EDIT_SELECTION_COMMANDS: {sectionMarker: Commands.EDIT_SELECT_ALL},
EDIT_FIND: {sectionMarker: Commands.EDIT_FIND},
EDIT_REPLACE_COMMANDS: {sectionMarker: Commands.EDIT_REPLACE},
EDIT_MODIFY_SELECTION: {sectionMarker: Commands.EDIT_INDENT},
EDIT_COMMENT_SELECTION: {sectionMarker: Commands.EDIT_LINE_COMMENT},

SEARCH_FIND_COMMANDS: {sectionMarker: Commands.SEARCH_FIND},
SEARCH_REPLACE_COMMANDS: {sectionMarker: Commands.SEARCH_REPLACE},
SEARCH_FIND_IN_FILES_COMMANDS: {sectionMarker: Commands.SEARCH_FIND_IN_FILES},

VIEW_HIDESHOW_COMMANDS: {sectionMarker: Commands.VIEW_HIDE_SIDEBAR},
VIEW_FONTSIZE_COMMANDS: {sectionMarker: Commands.VIEW_INCREASE_FONT_SIZE},
Expand Down
7 changes: 7 additions & 0 deletions src/htmlContent/search-dialog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{CMD_FIND}}:
<input type="text" id="searchInput" value="{{value}}" style="width: 10em" />
<div class="message">
<span id="searchlabel">{{{label}}}</span>
<span style="color: #888">({{SEARCH_REGEXP_INFO}})</span>
</div>
<div class="error"></div>
16 changes: 16 additions & 0 deletions src/htmlContent/search-results.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<table class="zebra-striped condensed-table">
<tbody>
{{#searchList}}
<tr class="file-section" data-file="{{file}}">
<td colspan="3"><span class="disclosure-triangle expanded"></span>{{{filename}}}</td>
</tr>
{{#items}}
<tr data-file="{{file}}" data-item="{{item}}">
<td></td>
<td style="white-space: nowrap">{{line}}</td>
<td>{{pre}}<span class="highlight">{{highlight}}</span>{{post}}</td>
</tr>
{{/items}}
{{/searchList}}
</tbody>
</table>
27 changes: 18 additions & 9 deletions src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,18 @@ define({

"FIND_IN_FILES_TITLE" : "for \"{4}\" {5} - {0} {1} in {2} {3}",
"FIND_IN_FILES_SCOPED" : "in <span class='dialog-filename'>{0}</span>",
"FIND_IN_FILES_NO_SCOPE" : "in project",
"FIND_IN_FILES_WORKING_SET" : "in working set",
"FIND_IN_FILES_PROJECT" : "in project",
"FIND_IN_FILES_FILE" : "file",
"FIND_IN_FILES_FILES" : "files",
"FIND_IN_FILES_MATCH" : "match",
"FIND_IN_FILES_MATCHES" : "matches",
"FIND_IN_FILES_MORE_THAN" : "More than ",
"FIND_IN_FILES_MAX" : " (showing the first {0} matches)",
"FIND_IN_FILES_PAGING" : " (showing matches {0} to {1})",
"FIND_IN_FILES_LESS" : " <a href='#' class='find-less'>Less</a>",
"FIND_IN_FILES_MORE" : " <a href='#' class='find-more'>More</a>",
"FIND_IN_FILES_FILE_PATH" : "File: <span class='dialog-filename'>{0}</span>",
"FIND_IN_FILES_LINE" : "line:&nbsp;{0}",
"FIND_IN_FILES_LINE" : "line: {0}",

"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 Expand Up @@ -188,12 +191,6 @@ define({
"CMD_PASTE" : "Paste",
"CMD_SELECT_ALL" : "Select All",
"CMD_SELECT_LINE" : "Select Line",
"CMD_FIND" : "Find",
"CMD_FIND_IN_FILES" : "Find in Files",
"CMD_FIND_IN_SUBTREE" : "Find in\u2026",
"CMD_FIND_NEXT" : "Find Next",
"CMD_FIND_PREVIOUS" : "Find Previous",
"CMD_REPLACE" : "Replace",
"CMD_INDENT" : "Indent",
"CMD_UNINDENT" : "Unindent",
"CMD_DUPLICATE" : "Duplicate",
Expand All @@ -204,6 +201,18 @@ define({
"CMD_LINE_DOWN" : "Move Line Down",
"CMD_TOGGLE_CLOSE_BRACKETS" : "Auto Close Braces",

// Search menu commands
"SEARCH_MENU" : "Search",
"CMD_FIND" : "Find",
"CMD_FIND_NEXT" : "Find Next",
"CMD_FIND_PREVIOUS" : "Find Previous",
"CMD_REPLACE" : "Replace",
"CMD_FIND_IN_FILES" : "Find in Project",
"CMD_FIND_IN_WORKING_SET" : "Find in Working Set",
"CMD_FIND_IN_SUBTREE" : "Find in File/Subtree",
"CMD_NEXT_RESULT" : "Next Result",
"CMD_PREVIOUS_RESULT" : "Previous Result",

// View menu commands
"VIEW_MENU" : "View",
"CMD_HIDE_SIDEBAR" : "Hide Sidebar",
Expand Down
23 changes: 20 additions & 3 deletions src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ define(function (require, exports, module) {
}

/**
* Returns the FileEntry or DirectoryEntry corresponding to the selected item, or null
* if no item is selected.
*
* Returns the FileEntry or DirectoryEntry corresponding to the item selected in the file tree, or null
* if no item is selected in the tree (though the working set may still have a selection; use
* getSidebarSelectedItem() to get the selection regardless of whether it's in the tree or working set).
* @return {?Entry}
*/
function getSelectedItem() {
Expand All @@ -192,6 +192,22 @@ define(function (require, exports, module) {
}
return null;
}

/**
* Returns the FileEntry or DirectoryEntry corresponding to the item selected in the sidebar panel, whether in
* the file tree OR in the working set; or null if no item is selected anywhere in the sidebar.
* @return {?Entry}
*/
function getSidebarSelectedItem() {
// Prefer file tree selection, else use working set selection
var selectedEntry = getSelectedItem();
if (!selectedEntry) {
var doc = DocumentManager.getCurrentDocument();
selectedEntry = (doc && doc.file);
}
return selectedEntry;
}


function _fileViewFocusChange() {
_redraw(true);
Expand Down Expand Up @@ -1386,6 +1402,7 @@ define(function (require, exports, module) {
exports.shouldShow = shouldShow;
exports.openProject = openProject;
exports.getSelectedItem = getSelectedItem;
exports.getSidebarSelectedItem = getSidebarSelectedItem;
exports.getInitialProjectPath = getInitialProjectPath;
exports.isWelcomeProjectPath = isWelcomeProjectPath;
exports.updateWelcomeProjectPath = updateWelcomeProjectPath;
Expand Down
Loading