From 06e9b2a5a5697b3d48381ed8315c9a998336f06f Mon Sep 17 00:00:00 2001 From: Lance Campbell Date: Fri, 11 Apr 2014 09:14:00 -0700 Subject: [PATCH 1/8] Add new Search menu --- src/base-config/keyboard.json | 104 ++++++++++----------- src/command/Commands.js | 28 +++--- src/command/DefaultMenus.js | 36 ++++---- src/command/Menus.js | 9 +- src/nls/root/strings.js | 23 ++--- src/search/FindInFiles.js | 6 +- src/search/FindReplace.js | 20 ++--- test/spec/FileFilters-test.js | 2 +- test/spec/FindReplace-test.js | 164 +++++++++++++++++----------------- 9 files changed, 202 insertions(+), 190 deletions(-) diff --git a/src/base-config/keyboard.json b/src/base-config/keyboard.json index d129d202ac7..76d4151d0d1 100644 --- a/src/base-config/keyboard.json +++ b/src/base-config/keyboard.json @@ -80,58 +80,6 @@ "displayKey": "Shift-Alt-↓" } ], - "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.findAllAndSelect": [ - { - "key": "Alt-F3" - }, - { - "key": "Cmd-Ctrl-G", - "platform": "mac" - } - ], - "edit.addNextMatch": [ - { - "key": "Ctrl-B" - } - ], - "edit.skipCurrentMatch": [ - { - "key": "Ctrl-Shift-B" - } - ], - "edit.replace": [ - { - "key": "Ctrl-H" - }, - { - "key": "Cmd-Alt-F", - "platform": "mac" - } - ], "edit.indent": [ { "key": "Ctrl-]" @@ -197,6 +145,58 @@ "platform": "mac" } ], + "search.find": [ + "Ctrl-F" + ], + "search.findInFiles": [ + "Ctrl-Shift-F" + ], + "search.findNext": [ + { + "key": "F3" + }, + { + "key": "Cmd-G", + "platform": "mac" + } + ], + "search.findPrevious": [ + { + "key": "Shift-F3" + }, + { + "key": "Cmd-Shift-G", + "platform": "mac" + } + ], + "search.findAllAndSelect": [ + { + "key": "Alt-F3" + }, + { + "key": "Cmd-Ctrl-G", + "platform": "mac" + } + ], + "search.addNextMatch": [ + { + "key": "Ctrl-B" + } + ], + "search.skipCurrentMatch": [ + { + "key": "Ctrl-Shift-B" + } + ], + "search.replace": [ + { + "key": "Ctrl-H" + }, + { + "key": "Cmd-Alt-F", + "platform": "mac" + } + ], "view.hideSidebar": [ "Ctrl-Shift-H" ], diff --git a/src/command/Commands.js b/src/command/Commands.js index 9dbd356269a..a8d40e9aad7 100644 --- a/src/command/Commands.js +++ b/src/command/Commands.js @@ -31,7 +31,7 @@ define(function (require, exports, module) { /** * List of constants for global command IDs. */ - + // FILE exports.FILE_NEW_UNTITLED = "file.newDoc"; // DocumentCommandHandlers.js handleFileNew() exports.FILE_NEW = "file.newFile"; // DocumentCommandHandlers.js handleFileNewInProject() @@ -72,15 +72,6 @@ define(function (require, exports, module) { exports.EDIT_SPLIT_SEL_INTO_LINES = "edit.splitSelIntoLines"; // EditorCommandHandlers.js splitSelIntoLines() exports.EDIT_ADD_CUR_TO_NEXT_LINE = "edit.addCursorToNextLine"; // EditorCommandHandlers.js addCursorToNextLine() exports.EDIT_ADD_CUR_TO_PREV_LINE = "edit.addCursorToPrevLine"; // EditorCommandHandlers.js addCursorToPrevLine() - exports.EDIT_FIND = "edit.find"; // FindReplace.js _launchFind() - exports.EDIT_FIND_IN_FILES = "edit.findInFiles"; // FindInFiles.js _doFindInFiles() - exports.EDIT_FIND_IN_SUBTREE = "edit.findInSubtree"; // FindInFiles.js _doFindInSubtree() - exports.EDIT_FIND_NEXT = "edit.findNext"; // FindReplace.js _findNext() - exports.EDIT_FIND_PREVIOUS = "edit.findPrevious"; // FindReplace.js _findPrevious() - exports.EDIT_FIND_ALL_AND_SELECT = "edit.findAllAndSelect"; // FindReplace.js _findAllAndSelect() - exports.EDIT_ADD_NEXT_MATCH = "edit.addNextMatch"; // FindReplace.js _expandAndAddNextToSelection() - exports.EDIT_SKIP_CURRENT_MATCH = "edit.skipCurrentMatch"; // FindReplace.js _skipCurrentMatch() - exports.EDIT_REPLACE = "edit.replace"; // FindReplace.js _replace() exports.EDIT_INDENT = "edit.indent"; // EditorCommandHandlers.js indentText() exports.EDIT_UNINDENT = "edit.unindent"; // EditorCommandHandlers.js unindentText() exports.EDIT_DUPLICATE = "edit.duplicate"; // EditorCommandHandlers.js duplicateText() @@ -93,7 +84,18 @@ define(function (require, exports, module) { exports.EDIT_OPEN_LINE_BELOW = "edit.openLineBelow"; // EditorCommandHandlers.js openLineBelow() exports.TOGGLE_CLOSE_BRACKETS = "edit.autoCloseBrackets"; // EditorOptionHandlers.js _getToggler() exports.SHOW_CODE_HINTS = "edit.showCodeHints"; // CodeHintManager.js _startNewSession() - + + // SEARCH + exports.SEARCH_FIND = "search.find"; // FindReplace.js _launchFind() + exports.SEARCH_FIND_IN_FILES = "search.findInFiles"; // FindInFiles.js _doFindInFiles() + exports.SEARCH_FIND_IN_SUBTREE = "search.findInSubtree"; // FindInFiles.js _doFindInSubtree() + exports.SEARCH_FIND_NEXT = "search.findNext"; // FindReplace.js _findNext() + exports.SEARCH_FIND_PREVIOUS = "search.findPrevious"; // FindReplace.js _findPrevious() + exports.SEARCH_FIND_ALL_AND_SELECT = "search.findAllAndSelect"; // FindReplace.js _findAllAndSelect() + exports.SEARCH_ADD_NEXT_MATCH = "search.addNextMatch"; // FindReplace.js _expandAndAddNextToSelection() + exports.SEARCH_SKIP_CURRENT_MATCH = "search.skipCurrentMatch"; // FindReplace.js _skipCurrentMatch() + exports.SEARCH_REPLACE = "search.replace"; // FindReplace.js _replace() + // VIEW exports.VIEW_HIDE_SIDEBAR = "view.hideSidebar"; // SidebarView.js toggle() exports.VIEW_INCREASE_FONT_SIZE = "view.increaseFontSize"; // ViewCommandHandlers.js _handleIncreaseFontSize() @@ -125,7 +127,7 @@ define(function (require, exports, module) { exports.QUICK_EDIT_NEXT_MATCH = "navigate.nextMatch"; // MultiRangeInlineEditor.js _nextRange() exports.QUICK_EDIT_PREV_MATCH = "navigate.previousMatch"; // MultiRangeInlineEditor.js _previousRange() exports.CSS_QUICK_EDIT_NEW_RULE = "navigate.newRule"; // CSSInlineEditor.js _handleNewRule() - + // HELP exports.HELP_CHECK_FOR_UPDATE = "help.checkForUpdate"; // HelpCommandHandlers.js _handleCheckForUpdates() exports.HELP_HOW_TO_USE_BRACKETS = "help.howToUseBrackets"; // HelpCommandHandlers.js _handleLinkMenuItem() @@ -138,7 +140,7 @@ define(function (require, exports, module) { // File shell callbacks - string must MATCH string in native code (appshell/command_callbacks.h) exports.HELP_ABOUT = "help.about"; // HelpCommandHandlers.js _handleAboutDialog() - + // APP exports.APP_RELOAD = "app.reload"; // DocumentCommandHandlers.js handleReload() exports.APP_RELOAD_WITHOUT_EXTS = "app.reload_without_exts"; // DocumentCommandHandlers.js handleReloadWithoutExts() diff --git a/src/command/DefaultMenus.js b/src/command/DefaultMenus.js index 56ff64834f4..94ed815f935 100644 --- a/src/command/DefaultMenus.js +++ b/src/command/DefaultMenus.js @@ -64,7 +64,7 @@ define(function (require, exports, module) { menu.addMenuDivider(); menu.addMenuItem(Commands.FILE_QUIT); } - + /* * Edit menu */ @@ -82,17 +82,6 @@ define(function (require, exports, module) { menu.addMenuItem(Commands.EDIT_ADD_CUR_TO_PREV_LINE); menu.addMenuItem(Commands.EDIT_ADD_CUR_TO_NEXT_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.addMenuItem(Commands.EDIT_FIND_ALL_AND_SELECT); - menu.addMenuItem(Commands.EDIT_ADD_NEXT_MATCH); - menu.addMenuItem(Commands.EDIT_SKIP_CURRENT_MATCH); - - menu.addMenuDivider(); - menu.addMenuItem(Commands.EDIT_REPLACE); - menu.addMenuDivider(); menu.addMenuItem(Commands.EDIT_INDENT); menu.addMenuItem(Commands.EDIT_UNINDENT); menu.addMenuItem(Commands.EDIT_DUPLICATE); @@ -106,7 +95,22 @@ define(function (require, exports, module) { menu.addMenuItem(Commands.SHOW_CODE_HINTS); 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.addMenuItem(Commands.SEARCH_FIND_ALL_AND_SELECT); + menu.addMenuItem(Commands.SEARCH_ADD_NEXT_MATCH); + menu.addMenuItem(Commands.SEARCH_SKIP_CURRENT_MATCH); + menu.addMenuDivider(); + menu.addMenuItem(Commands.SEARCH_FIND_IN_FILES); + menu.addMenuDivider(); + menu.addMenuItem(Commands.SEARCH_REPLACE); + /* * View menu */ @@ -146,7 +150,7 @@ define(function (require, exports, module) { menu.addMenuItem(Commands.CSS_QUICK_EDIT_NEW_RULE); menu.addMenuDivider(); menu.addMenuItem(Commands.TOGGLE_QUICK_DOCS); - + /* * Help menu */ @@ -199,7 +203,7 @@ define(function (require, exports, module) { project_cmenu.addMenuItem(Commands.FILE_DELETE); project_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_OS); project_cmenu.addMenuDivider(); - project_cmenu.addMenuItem(Commands.EDIT_FIND_IN_SUBTREE); + project_cmenu.addMenuItem(Commands.SEARCH_FIND_IN_SUBTREE); project_cmenu.addMenuDivider(); project_cmenu.addMenuItem(Commands.FILE_REFRESH); @@ -210,7 +214,7 @@ define(function (require, exports, module) { working_set_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_FILE_TREE); working_set_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_OS); 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.FILE_CLOSE); diff --git a/src/command/Menus.js b/src/command/Menus.js index 306ad53bb83..36e07abfa6f 100644 --- a/src/command/Menus.js +++ b/src/command/Menus.js @@ -46,6 +46,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" @@ -85,13 +86,15 @@ define(function (require, exports, module) { 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_COMMANDS: {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}, EDIT_CODE_HINTS_COMMANDS: {sectionMarker: Commands.SHOW_CODE_HINTS}, EDIT_TOGGLE_OPTIONS: {sectionMarker: Commands.TOGGLE_CLOSE_BRACKETS}, - + + SEARCH_FIND_COMMANDS: {sectionMarker: Commands.SEARCH_FIND}, + SEARCH_FIND_IN_COMMANDS: {sectionMarker: Commands.SEARCH_FIND_IN_FILES}, + SEARCH_REPLACE_COMMANDS: {sectionMarker: Commands.SEARCH_REPLACE}, + VIEW_HIDESHOW_COMMANDS: {sectionMarker: Commands.VIEW_HIDE_SIDEBAR}, VIEW_FONTSIZE_COMMANDS: {sectionMarker: Commands.VIEW_INCREASE_FONT_SIZE}, VIEW_TOGGLE_OPTIONS: {sectionMarker: Commands.TOGGLE_ACTIVE_LINE}, diff --git a/src/nls/root/strings.js b/src/nls/root/strings.js index 538a9d62735..81b34a6db49 100644 --- a/src/nls/root/strings.js +++ b/src/nls/root/strings.js @@ -289,16 +289,6 @@ define({ "CMD_SPLIT_SEL_INTO_LINES" : "Split Selection into Lines", "CMD_ADD_CUR_TO_NEXT_LINE" : "Add Cursor to Next Line", "CMD_ADD_CUR_TO_PREV_LINE" : "Add Cursor to Previous Line", - "CMD_FIND" : "Find", - "CMD_FIND_FIELD_PLACEHOLDER" : "Find\u2026", - "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_FIND_ALL_AND_SELECT" : "Find All and Select", - "CMD_ADD_NEXT_MATCH" : "Add Next Match to Selection", - "CMD_SKIP_CURRENT_MATCH" : "Skip and Add Next Match", - "CMD_REPLACE" : "Replace", "CMD_INDENT" : "Indent", "CMD_UNINDENT" : "Unindent", "CMD_DUPLICATE" : "Duplicate", @@ -312,6 +302,19 @@ define({ "CMD_TOGGLE_CLOSE_BRACKETS" : "Auto Close Braces", "CMD_SHOW_CODE_HINTS" : "Show Code Hints", + // Search menu commands + "SEARCH_MENU" : "Search", + "CMD_FIND" : "Find", + "CMD_FIND_FIELD_PLACEHOLDER" : "Find\u2026", + "CMD_FIND_NEXT" : "Find Next", + "CMD_FIND_PREVIOUS" : "Find Previous", + "CMD_FIND_ALL_AND_SELECT" : "Find All and Select", + "CMD_ADD_NEXT_MATCH" : "Add Next Match to Selection", + "CMD_SKIP_CURRENT_MATCH" : "Skip and Add Next Match", + "CMD_FIND_IN_FILES" : "Find in Files", + "CMD_FIND_IN_SUBTREE" : "Find in\u2026", + "CMD_REPLACE" : "Replace", + // View menu commands "VIEW_MENU" : "View", "CMD_HIDE_SIDEBAR" : "Hide Sidebar", diff --git a/src/search/FindInFiles.js b/src/search/FindInFiles.js index a203ea792df..58cfd5be597 100644 --- a/src/search/FindInFiles.js +++ b/src/search/FindInFiles.js @@ -1042,7 +1042,7 @@ define(function (require, exports, module) { if (scope instanceof InMemoryFile) { CommandManager.execute(Commands.FILE_OPEN, { fullPath: scope.fullPath }).done(function () { - CommandManager.execute(Commands.EDIT_FIND); + CommandManager.execute(Commands.SEARCH_FIND); }); return; } @@ -1237,8 +1237,8 @@ define(function (require, exports, module) { }); // Initialize: command handlers - CommandManager.register(Strings.CMD_FIND_IN_FILES, Commands.EDIT_FIND_IN_FILES, _doFindInFiles); - CommandManager.register(Strings.CMD_FIND_IN_SUBTREE, Commands.EDIT_FIND_IN_SUBTREE, _doFindInSubtree); + CommandManager.register(Strings.CMD_FIND_IN_FILES, Commands.SEARCH_FIND_IN_FILES, _doFindInFiles); + CommandManager.register(Strings.CMD_FIND_IN_SUBTREE, Commands.SEARCH_FIND_IN_SUBTREE, _doFindInSubtree); // For unit testing - updated in _doSearch() when search complete exports._searchResults = null; diff --git a/src/search/FindReplace.js b/src/search/FindReplace.js index 6e4adba5fe3..3b97782ac2b 100644 --- a/src/search/FindReplace.js +++ b/src/search/FindReplace.js @@ -602,8 +602,8 @@ define(function (require, exports, module) { // Create the search bar UI (closing any previous modalBar in the process) var htmlContent = Mustache.render(searchBarTemplate, $.extend(templateVars, Strings)); createModalBar(htmlContent); - addShortcutToTooltip($("#find-next"), Commands.EDIT_FIND_NEXT); - addShortcutToTooltip($("#find-prev"), Commands.EDIT_FIND_PREVIOUS); + addShortcutToTooltip($("#find-next"), Commands.SEARCH_FIND_NEXT); + addShortcutToTooltip($("#find-prev"), Commands.SEARCH_FIND_PREVIOUS); $(modalBar).on("close", function (e, query) { // Clear highlights but leave search state in place so Find Next/Previous work after closing @@ -813,7 +813,7 @@ define(function (require, exports, module) { } openSearchBar(editor, {replace: true}); - addShortcutToTooltip($("#replace-yes"), Commands.EDIT_REPLACE); + addShortcutToTooltip($("#replace-yes"), Commands.SEARCH_REPLACE); var cm = editor._codeMirror, state = getSearchState(cm); @@ -912,13 +912,13 @@ define(function (require, exports, module) { $(DocumentManager).on("currentDocumentChange", _handleDocumentChange); - CommandManager.register(Strings.CMD_FIND, Commands.EDIT_FIND, _launchFind); - CommandManager.register(Strings.CMD_FIND_NEXT, Commands.EDIT_FIND_NEXT, _findNext); - CommandManager.register(Strings.CMD_REPLACE, Commands.EDIT_REPLACE, _replace); - CommandManager.register(Strings.CMD_FIND_PREVIOUS, Commands.EDIT_FIND_PREVIOUS, _findPrevious); - CommandManager.register(Strings.CMD_FIND_ALL_AND_SELECT, Commands.EDIT_FIND_ALL_AND_SELECT, _findAllAndSelect); - CommandManager.register(Strings.CMD_ADD_NEXT_MATCH, Commands.EDIT_ADD_NEXT_MATCH, _expandWordAndAddNextToSelection); - CommandManager.register(Strings.CMD_SKIP_CURRENT_MATCH, Commands.EDIT_SKIP_CURRENT_MATCH, _skipCurrentMatch); + CommandManager.register(Strings.CMD_FIND, Commands.SEARCH_FIND, _launchFind); + CommandManager.register(Strings.CMD_FIND_NEXT, Commands.SEARCH_FIND_NEXT, _findNext); + CommandManager.register(Strings.CMD_REPLACE, Commands.SEARCH_REPLACE, _replace); + CommandManager.register(Strings.CMD_FIND_PREVIOUS, Commands.SEARCH_FIND_PREVIOUS, _findPrevious); + CommandManager.register(Strings.CMD_FIND_ALL_AND_SELECT, Commands.SEARCH_FIND_ALL_AND_SELECT, _findAllAndSelect); + CommandManager.register(Strings.CMD_ADD_NEXT_MATCH, Commands.SEARCH_ADD_NEXT_MATCH, _expandWordAndAddNextToSelection); + CommandManager.register(Strings.CMD_SKIP_CURRENT_MATCH, Commands.SEARCH_SKIP_CURRENT_MATCH, _skipCurrentMatch); // APIs shared with FindInFiles exports._updatePrefsFromSearchBar = _updatePrefsFromSearchBar; diff --git a/test/spec/FileFilters-test.js b/test/spec/FileFilters-test.js index 19cb6003048..6f21d3680bf 100644 --- a/test/spec/FileFilters-test.js +++ b/test/spec/FileFilters-test.js @@ -463,7 +463,7 @@ define(function (require, exports, module) { }, "search bar close"); }); runs(function () { - waitsForDone(CommandManager.execute(Commands.EDIT_FIND_IN_FILES)); + waitsForDone(CommandManager.execute(Commands.SEARCH_FIND_IN_FILES)); }); } diff --git a/test/spec/FindReplace-test.js b/test/spec/FindReplace-test.js index 1c9cc97cb14..00c0f3177aa 100644 --- a/test/spec/FindReplace-test.js +++ b/test/spec/FindReplace-test.js @@ -358,7 +358,7 @@ define(function (require, exports, module) { var i; for (i = 0; i < selections.length; i++) { expectSelection(selections[i]); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); } // next find should wraparound @@ -484,24 +484,24 @@ define(function (require, exports, module) { it("should find all case-insensitive matches with lowercase text", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); enterSearchText("foo"); expectHighlightedMatches(fooExpectedMatches); expectSelection(fooExpectedMatches[0]); expect(myEditor.centerOnCursor.calls.length).toEqual(1); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(fooExpectedMatches[1]); expect(myEditor.centerOnCursor.calls.length).toEqual(2); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(fooExpectedMatches[2]); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(fooExpectedMatches[3]); expectHighlightedMatches(fooExpectedMatches); // no change in highlights // wraparound - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(fooExpectedMatches[0]); expect(myEditor.centerOnCursor.calls.length).toEqual(5); }); @@ -509,24 +509,24 @@ define(function (require, exports, module) { it("should find all case-insensitive matches with mixed-case text", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); enterSearchText("Foo"); expectHighlightedMatches(fooExpectedMatches); expectSelection(fooExpectedMatches[0]); expect(myEditor.centerOnCursor.calls.length).toEqual(1); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(fooExpectedMatches[1]); expect(myEditor.centerOnCursor.calls.length).toEqual(2); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(fooExpectedMatches[2]); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(fooExpectedMatches[3]); expectHighlightedMatches(fooExpectedMatches); // no change in highlights // wraparound - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(fooExpectedMatches[0]); expect(myEditor.centerOnCursor.calls.length).toEqual(5); }); @@ -534,28 +534,28 @@ define(function (require, exports, module) { it("should find all case-sensitive matches with mixed-case text", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); toggleCaseSensitive(true); enterSearchText("Foo"); expectHighlightedMatches(capitalFooSelections); expectSelection(capitalFooSelections[0]); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(capitalFooSelections[1]); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(capitalFooSelections[2]); // note the lowercase "foo()" is NOT matched // wraparound - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(capitalFooSelections[0]); }); it("toggling case-sensitive option should update results immediately", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); enterSearchText("Foo"); expectHighlightedMatches(fooExpectedMatches); @@ -565,7 +565,7 @@ define(function (require, exports, module) { expectHighlightedMatches(capitalFooSelections); expectSelection(capitalFooSelections[0]); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(capitalFooSelections[1]); }); @@ -574,7 +574,7 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); enterSearchText("foo"); pressEscape(); @@ -588,16 +588,16 @@ define(function (require, exports, module) { expect(myEditor.centerOnCursor.calls.length).toEqual(1); // Simple linear Find Next - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: 31}, end: {line: LINE_FIRST_REQUIRE, ch: 34}}); expect(myEditor.centerOnCursor.calls.length).toEqual(2); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection({start: {line: 6, ch: 17}, end: {line: 6, ch: 20}}); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection({start: {line: 8, ch: 8}, end: {line: 8, ch: 11}}); // Wrap around to first result - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: 8}, end: {line: LINE_FIRST_REQUIRE, ch: 11}}); }); }); @@ -606,7 +606,7 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); enterSearchText("foo"); pressEscape(); @@ -618,15 +618,15 @@ define(function (require, exports, module) { expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: 8}, end: {line: LINE_FIRST_REQUIRE, ch: 11}}); // Wrap around to last result - twCommandManager.execute(Commands.EDIT_FIND_PREVIOUS); + twCommandManager.execute(Commands.SEARCH_FIND_PREVIOUS); expectSelection({start: {line: 8, ch: 8}, end: {line: 8, ch: 11}}); // Simple linear Find Previous - twCommandManager.execute(Commands.EDIT_FIND_PREVIOUS); + twCommandManager.execute(Commands.SEARCH_FIND_PREVIOUS); expectSelection({start: {line: 6, ch: 17}, end: {line: 6, ch: 20}}); - twCommandManager.execute(Commands.EDIT_FIND_PREVIOUS); + twCommandManager.execute(Commands.SEARCH_FIND_PREVIOUS); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: 31}, end: {line: LINE_FIRST_REQUIRE, ch: 34}}); - twCommandManager.execute(Commands.EDIT_FIND_PREVIOUS); + twCommandManager.execute(Commands.SEARCH_FIND_PREVIOUS); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: 8}, end: {line: LINE_FIRST_REQUIRE, ch: 11}}); }); }); @@ -635,7 +635,7 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); enterSearchText("foo"); pressEscape(); @@ -647,19 +647,19 @@ define(function (require, exports, module) { runs(function () { expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: 8}, end: {line: LINE_FIRST_REQUIRE, ch: 11}}); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: 31}, end: {line: LINE_FIRST_REQUIRE, ch: 34}}); // skip forward myEditor.setCursorPos(7, 0); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection({start: {line: 8, ch: 8}, end: {line: 8, ch: 11}}); // skip backward myEditor.setCursorPos(LINE_FIRST_REQUIRE, 14); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: 31}, end: {line: LINE_FIRST_REQUIRE, ch: 34}}); }); }); @@ -668,7 +668,7 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); toggleCaseSensitive(true); enterSearchText("Foo"); @@ -687,7 +687,7 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); enterSearchText("foo"); pressEscape(); @@ -698,12 +698,12 @@ define(function (require, exports, module) { runs(function () { // Open search bar a second time myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); expectSearchBarOpen(); expect(myEditor).toHaveCursorPosition(0, 0); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expect(myEditor).toHaveCursorPosition(0, 0); }); }); @@ -711,7 +711,7 @@ define(function (require, exports, module) { it("should open search bar on Find Next with no previous search", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSearchBarOpen(); expect(myEditor).toHaveCursorPosition(0, 0); @@ -721,7 +721,7 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); enterSearchText("foo"); // position cursor first @@ -732,7 +732,7 @@ define(function (require, exports, module) { expect(myEditor).toHaveCursorPosition(LINE_FIRST_REQUIRE, 11); // cursor left at end of last good match ("foo") // Invoke Find a 2nd time - this time while search bar is open - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); }); waitsForSearchBarReopen(); @@ -753,7 +753,7 @@ define(function (require, exports, module) { it("should re-search from original position when text changes", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); enterSearchText("baz"); @@ -773,14 +773,14 @@ define(function (require, exports, module) { it("should re-search from original position when text changes, even after Find Next", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); enterSearchText("foo"); expectSelection(fooExpectedMatches[0]); // get search highlight down below where the "bar" match will be - twCommandManager.execute(Commands.EDIT_FIND_NEXT); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(fooExpectedMatches[2]); enterSearchText("bar"); @@ -790,14 +790,14 @@ define(function (require, exports, module) { it("should get primary selection as initial query", function () { myEditor.setSelections([{start: {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_START}, end: {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_PAREN}, primary: true}, {start: {line: 1, ch: 0}, end: {line: 1, ch: 1}}]); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); expect(getSearchField().val()).toEqual("require"); }); it("should extend original selection when appending to prepopulated text", function () { myEditor.setSelection({line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_START}, {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_PAREN}); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); expect(getSearchField().val()).toEqual("require"); var requireExpectedMatches = [ @@ -821,7 +821,7 @@ define(function (require, exports, module) { it("should collapse selection when appending to prepopulated text causes no result", function () { myEditor.setSelection({line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_START}, {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_PAREN}); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_START}, end: {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_PAREN}}); enterSearchText("requireX"); @@ -832,7 +832,7 @@ define(function (require, exports, module) { it("should clear selection, return cursor to start after backspacing to empty query", function () { myEditor.setCursorPos(2, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); enterSearchText("require"); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_START}, end: {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_PAREN}}); @@ -844,7 +844,7 @@ define(function (require, exports, module) { it("should incremental search & highlight from Replace mode too", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); enterSearchText("baz"); var expectedSelections = [ @@ -869,7 +869,7 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(LINE_FIRST_REQUIRE, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); expect(myEditor).toHaveCursorPosition(LINE_FIRST_REQUIRE, 0); enterSearchText("require"); @@ -889,13 +889,13 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(LINE_FIRST_REQUIRE, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); expect(myEditor).toHaveCursorPosition(LINE_FIRST_REQUIRE, 0); enterSearchText("require"); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_START}, end: {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_PAREN}}); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection({start: {line: LINE_FIRST_REQUIRE + 1, ch: CH_REQUIRE_START}, end: {line: LINE_FIRST_REQUIRE + 1, ch: CH_REQUIRE_PAREN}}); pressEscape(); @@ -911,10 +911,10 @@ define(function (require, exports, module) { it("should no-op on Find Next with blank search", function () { myEditor.setCursorPos(LINE_FIRST_REQUIRE, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); expect(myEditor).toHaveCursorPosition(LINE_FIRST_REQUIRE, 0); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expect(myEditor).toHaveCursorPosition(LINE_FIRST_REQUIRE, 0); // no change }); @@ -931,7 +931,7 @@ define(function (require, exports, module) { ]; myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); toggleRegexp(true); toggleCaseSensitive(true); @@ -939,15 +939,15 @@ define(function (require, exports, module) { expectHighlightedMatches(expectedSelections); expectSelection(expectedSelections[0]); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(expectedSelections[1]); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(expectedSelections[2]); - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(expectedSelections[3]); // wraparound - twCommandManager.execute(Commands.EDIT_FIND_NEXT); + twCommandManager.execute(Commands.SEARCH_FIND_NEXT); expectSelection(expectedSelections[0]); }); @@ -963,7 +963,7 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); toggleRegexp(true); enterSearchText("Ba."); @@ -977,7 +977,7 @@ define(function (require, exports, module) { expectFindNextSelections(expectedSelections); // explicitly clean up since we closed the search bar - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); toggleRegexp(false); }); }); @@ -985,7 +985,7 @@ define(function (require, exports, module) { it("toggling regexp option should update results immediately", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); enterSearchText("t ."); expectHighlightedMatches([]); @@ -1006,7 +1006,7 @@ define(function (require, exports, module) { ]; myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); toggleRegexp(true); toggleCaseSensitive(true); @@ -1024,7 +1024,7 @@ define(function (require, exports, module) { ]; myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); toggleRegexp(true); toggleCaseSensitive(false); @@ -1036,7 +1036,7 @@ define(function (require, exports, module) { it("shouldn't choke on invalid regexp", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); toggleRegexp(true); enterSearchText("+"); @@ -1048,7 +1048,7 @@ define(function (require, exports, module) { it("shouldn't choke on empty regexp", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); toggleRegexp(true); enterSearchText(""); @@ -1059,7 +1059,7 @@ define(function (require, exports, module) { it("shouldn't freeze on /.*/ regexp", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.EDIT_FIND); + twCommandManager.execute(Commands.SEARCH_FIND); toggleRegexp(true); enterSearchText(".*/"); @@ -1071,7 +1071,7 @@ define(function (require, exports, module) { describe("Search -> Replace", function () { it("should find and replace one string", function () { runs(function () { - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); enterSearchText("foo"); expectSelection(fooExpectedMatches[0]); @@ -1090,13 +1090,13 @@ define(function (require, exports, module) { it("should use replace keyboard shortcut for single Replace while search bar open", function () { runs(function () { - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); enterSearchText("foo"); expectSelection(fooExpectedMatches[0]); enterReplaceText("bar"); - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); expectSelection(fooExpectedMatches[1]); myEditor.setSelection(fooExpectedMatches[0].start, fooExpectedMatches[0].end); @@ -1106,7 +1106,7 @@ define(function (require, exports, module) { it("should find and replace a regexp with $n substitutions", function () { runs(function () { - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("$2:$1"); @@ -1126,7 +1126,7 @@ define(function (require, exports, module) { it("should find a regexp and replace it with $0n (leading zero)", function () { runs(function () { - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("$02:$01"); @@ -1146,7 +1146,7 @@ define(function (require, exports, module) { it("should find a regexp and replace it with $0 (literal)", function () { runs(function () { - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("$0_:$01"); @@ -1166,7 +1166,7 @@ define(function (require, exports, module) { it("should find a regexp and replace it with $n (empty subexpression)", function () { runs(function () { - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); toggleRegexp(true); enterSearchText("(modules)(.*)\\/(\\w+)"); enterReplaceText("$3$2:$1"); @@ -1186,7 +1186,7 @@ define(function (require, exports, module) { it("should find a regexp and replace it with $nn (n has two digits)", function () { runs(function () { - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); toggleRegexp(true); enterSearchText("()()()()()()()()()()(modules)\\/()()()(\\w+)"); enterReplaceText("$15:$11"); @@ -1206,7 +1206,7 @@ define(function (require, exports, module) { it("should find a regexp and replace it with $$n (not a subexpression, escaped dollar)", function () { runs(function () { - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("$$2_$$10:$2"); @@ -1226,7 +1226,7 @@ define(function (require, exports, module) { it("should find a regexp and replace it with $$$n (correct subexpression)", function () { runs(function () { - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("$2$$$1"); @@ -1246,7 +1246,7 @@ define(function (require, exports, module) { it("should find a regexp and replace it with $& (whole match)", function () { runs(function () { - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("_$&-$2$$&"); @@ -1269,7 +1269,7 @@ define(function (require, exports, module) { describe("Search -> Replace All", function () { it("should find all regexps and replace them with $n", function () { runs(function () { - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("$2:$1"); @@ -1296,7 +1296,7 @@ define(function (require, exports, module) { it("should find all regexps and replace them with $n (empty subexpression)", function () { runs(function () { - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); toggleRegexp(true); enterSearchText("(modules)(.*)\\/(\\w+)"); enterReplaceText("$3$2:$1"); @@ -1323,7 +1323,7 @@ define(function (require, exports, module) { it("should find all regexps and replace them with $nn (n has two digits)", function () { runs(function () { - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); toggleRegexp(true); enterSearchText("()()()()()()()()()()(modules)\\/()()()(\\w+)"); enterReplaceText("$15:$11"); @@ -1350,7 +1350,7 @@ define(function (require, exports, module) { it("should find all regexps and replace them with $$n (not a subexpression, escaped dollar)", function () { runs(function () { - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("$$2_$$10:$2"); @@ -1377,7 +1377,7 @@ define(function (require, exports, module) { it("should find all regexps and replace them with $$$n (correct subexpression)", function () { runs(function () { - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("$2$$$1"); @@ -1404,7 +1404,7 @@ define(function (require, exports, module) { it("should find all regexps and replace them with $& (whole match)", function () { runs(function () { - twCommandManager.execute(Commands.EDIT_REPLACE); + twCommandManager.execute(Commands.SEARCH_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("_$&-$2$$&"); From 7317a29a57e25094a37a3d9fe1fcebc01b91f7dc Mon Sep 17 00:00:00 2001 From: Lance Campbell Date: Fri, 11 Apr 2014 09:52:32 -0700 Subject: [PATCH 2/8] Add 'Find in Selected File/Folder' menu item --- src/command/Commands.js | 18 +++++++++--------- src/command/DefaultMenus.js | 1 + src/nls/root/strings.js | 1 + src/search/FindInFiles.js | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/command/Commands.js b/src/command/Commands.js index a8d40e9aad7..eaee62ef6b4 100644 --- a/src/command/Commands.js +++ b/src/command/Commands.js @@ -86,15 +86,15 @@ define(function (require, exports, module) { exports.SHOW_CODE_HINTS = "edit.showCodeHints"; // CodeHintManager.js _startNewSession() // SEARCH - exports.SEARCH_FIND = "search.find"; // FindReplace.js _launchFind() - exports.SEARCH_FIND_IN_FILES = "search.findInFiles"; // FindInFiles.js _doFindInFiles() - exports.SEARCH_FIND_IN_SUBTREE = "search.findInSubtree"; // FindInFiles.js _doFindInSubtree() - exports.SEARCH_FIND_NEXT = "search.findNext"; // FindReplace.js _findNext() - exports.SEARCH_FIND_PREVIOUS = "search.findPrevious"; // FindReplace.js _findPrevious() - exports.SEARCH_FIND_ALL_AND_SELECT = "search.findAllAndSelect"; // FindReplace.js _findAllAndSelect() - exports.SEARCH_ADD_NEXT_MATCH = "search.addNextMatch"; // FindReplace.js _expandAndAddNextToSelection() - exports.SEARCH_SKIP_CURRENT_MATCH = "search.skipCurrentMatch"; // FindReplace.js _skipCurrentMatch() - exports.SEARCH_REPLACE = "search.replace"; // FindReplace.js _replace() + exports.SEARCH_FIND = "search.find"; // FindReplace.js _launchFind() + exports.SEARCH_FIND_IN_FILES = "search.findInFiles"; // FindInFiles.js _doFindInFiles() + exports.SEARCH_FIND_IN_SUBTREE = "search.findInSubtree"; // FindInFiles.js _doFindInSubtree() + exports.SEARCH_FIND_NEXT = "search.findNext"; // FindReplace.js _findNext() + exports.SEARCH_FIND_PREVIOUS = "search.findPrevious"; // FindReplace.js _findPrevious() + exports.SEARCH_FIND_ALL_AND_SELECT = "search.findAllAndSelect"; // FindReplace.js _findAllAndSelect() + exports.SEARCH_ADD_NEXT_MATCH = "search.addNextMatch"; // FindReplace.js _expandAndAddNextToSelection() + exports.SEARCH_SKIP_CURRENT_MATCH = "search.skipCurrentMatch"; // FindReplace.js _skipCurrentMatch() + exports.SEARCH_REPLACE = "search.replace"; // FindReplace.js _replace() // VIEW exports.VIEW_HIDE_SIDEBAR = "view.hideSidebar"; // SidebarView.js toggle() diff --git a/src/command/DefaultMenus.js b/src/command/DefaultMenus.js index 94ed815f935..123d5ee57cb 100644 --- a/src/command/DefaultMenus.js +++ b/src/command/DefaultMenus.js @@ -108,6 +108,7 @@ define(function (require, exports, module) { menu.addMenuItem(Commands.SEARCH_SKIP_CURRENT_MATCH); menu.addMenuDivider(); menu.addMenuItem(Commands.SEARCH_FIND_IN_FILES); + menu.addMenuItem(Commands.SEARCH_FIND_IN_SUBTREE); menu.addMenuDivider(); menu.addMenuItem(Commands.SEARCH_REPLACE); diff --git a/src/nls/root/strings.js b/src/nls/root/strings.js index 81b34a6db49..8d30ce8b3f6 100644 --- a/src/nls/root/strings.js +++ b/src/nls/root/strings.js @@ -312,6 +312,7 @@ define({ "CMD_ADD_NEXT_MATCH" : "Add Next Match to Selection", "CMD_SKIP_CURRENT_MATCH" : "Skip and Add Next Match", "CMD_FIND_IN_FILES" : "Find in Files", + "CMD_FIND_IN_SELECTED" : "Find in Selected File/Folder", "CMD_FIND_IN_SUBTREE" : "Find in\u2026", "CMD_REPLACE" : "Replace", diff --git a/src/search/FindInFiles.js b/src/search/FindInFiles.js index 58cfd5be597..08a3bed2ea6 100644 --- a/src/search/FindInFiles.js +++ b/src/search/FindInFiles.js @@ -1237,8 +1237,8 @@ define(function (require, exports, module) { }); // Initialize: command handlers - CommandManager.register(Strings.CMD_FIND_IN_FILES, Commands.SEARCH_FIND_IN_FILES, _doFindInFiles); - CommandManager.register(Strings.CMD_FIND_IN_SUBTREE, Commands.SEARCH_FIND_IN_SUBTREE, _doFindInSubtree); + CommandManager.register(Strings.CMD_FIND_IN_FILES, Commands.SEARCH_FIND_IN_FILES, _doFindInFiles); + CommandManager.register(Strings.CMD_FIND_IN_SUBTREE, Commands.SEARCH_FIND_IN_SUBTREE, _doFindInSubtree); // For unit testing - updated in _doSearch() when search complete exports._searchResults = null; From 42cd989b70688ad2f1e7edb239e677c9f0f90b1d Mon Sep 17 00:00:00 2001 From: Lance Campbell Date: Fri, 11 Apr 2014 10:16:32 -0700 Subject: [PATCH 3/8] Give 'Find in Selected' it's own Command --- src/command/Commands.js | 1 + src/command/DefaultMenus.js | 2 +- src/search/FindInFiles.js | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/command/Commands.js b/src/command/Commands.js index eaee62ef6b4..1de42a7610c 100644 --- a/src/command/Commands.js +++ b/src/command/Commands.js @@ -88,6 +88,7 @@ define(function (require, exports, module) { // SEARCH exports.SEARCH_FIND = "search.find"; // FindReplace.js _launchFind() exports.SEARCH_FIND_IN_FILES = "search.findInFiles"; // FindInFiles.js _doFindInFiles() + exports.SEARCH_FIND_IN_SELECTED = "search.findInSelected"; // FindInFiles.js _doFindInSubtree() exports.SEARCH_FIND_IN_SUBTREE = "search.findInSubtree"; // FindInFiles.js _doFindInSubtree() exports.SEARCH_FIND_NEXT = "search.findNext"; // FindReplace.js _findNext() exports.SEARCH_FIND_PREVIOUS = "search.findPrevious"; // FindReplace.js _findPrevious() diff --git a/src/command/DefaultMenus.js b/src/command/DefaultMenus.js index 123d5ee57cb..105253b36a3 100644 --- a/src/command/DefaultMenus.js +++ b/src/command/DefaultMenus.js @@ -108,7 +108,7 @@ define(function (require, exports, module) { menu.addMenuItem(Commands.SEARCH_SKIP_CURRENT_MATCH); menu.addMenuDivider(); menu.addMenuItem(Commands.SEARCH_FIND_IN_FILES); - menu.addMenuItem(Commands.SEARCH_FIND_IN_SUBTREE); + menu.addMenuItem(Commands.SEARCH_FIND_IN_SELECTED); menu.addMenuDivider(); menu.addMenuItem(Commands.SEARCH_REPLACE); diff --git a/src/search/FindInFiles.js b/src/search/FindInFiles.js index 08a3bed2ea6..21288754435 100644 --- a/src/search/FindInFiles.js +++ b/src/search/FindInFiles.js @@ -1237,8 +1237,9 @@ define(function (require, exports, module) { }); // Initialize: command handlers - CommandManager.register(Strings.CMD_FIND_IN_FILES, Commands.SEARCH_FIND_IN_FILES, _doFindInFiles); - CommandManager.register(Strings.CMD_FIND_IN_SUBTREE, Commands.SEARCH_FIND_IN_SUBTREE, _doFindInSubtree); + CommandManager.register(Strings.CMD_FIND_IN_FILES, Commands.SEARCH_FIND_IN_FILES, _doFindInFiles); + CommandManager.register(Strings.CMD_FIND_IN_SELECTED, Commands.SEARCH_FIND_IN_SELECTED, _doFindInSubtree); + CommandManager.register(Strings.CMD_FIND_IN_SUBTREE, Commands.SEARCH_FIND_IN_SUBTREE, _doFindInSubtree); // For unit testing - updated in _doSearch() when search complete exports._searchResults = null; From d2980036b4c3e91ef43bc6e6c07c6a8b422f2c3d Mon Sep 17 00:00:00 2001 From: Lance Campbell Date: Tue, 15 Apr 2014 15:08:03 -0700 Subject: [PATCH 4/8] Change Search to Find. Replace SEARCH prefix with CMD prefix. --- src/base-config/keyboard.json | 16 ++-- src/command/Commands.js | 22 ++--- src/command/DefaultMenus.js | 26 +++--- src/command/Menus.js | 8 +- src/nls/root/strings.js | 2 +- src/search/FindInFiles.js | 8 +- src/search/FindReplace.js | 20 ++--- test/spec/FileFilters-test.js | 2 +- test/spec/FindReplace-test.js | 164 +++++++++++++++++----------------- 9 files changed, 134 insertions(+), 134 deletions(-) diff --git a/src/base-config/keyboard.json b/src/base-config/keyboard.json index 76d4151d0d1..d25448fec91 100644 --- a/src/base-config/keyboard.json +++ b/src/base-config/keyboard.json @@ -145,13 +145,13 @@ "platform": "mac" } ], - "search.find": [ + "cmd.find": [ "Ctrl-F" ], - "search.findInFiles": [ + "cmd.findInFiles": [ "Ctrl-Shift-F" ], - "search.findNext": [ + "cmd.findNext": [ { "key": "F3" }, @@ -160,7 +160,7 @@ "platform": "mac" } ], - "search.findPrevious": [ + "cmd.findPrevious": [ { "key": "Shift-F3" }, @@ -169,7 +169,7 @@ "platform": "mac" } ], - "search.findAllAndSelect": [ + "cmd.findAllAndSelect": [ { "key": "Alt-F3" }, @@ -178,17 +178,17 @@ "platform": "mac" } ], - "search.addNextMatch": [ + "cmd.addNextMatch": [ { "key": "Ctrl-B" } ], - "search.skipCurrentMatch": [ + "cmd.skipCurrentMatch": [ { "key": "Ctrl-Shift-B" } ], - "search.replace": [ + "cmd.replace": [ { "key": "Ctrl-H" }, diff --git a/src/command/Commands.js b/src/command/Commands.js index 1de42a7610c..88f36243302 100644 --- a/src/command/Commands.js +++ b/src/command/Commands.js @@ -85,17 +85,17 @@ define(function (require, exports, module) { exports.TOGGLE_CLOSE_BRACKETS = "edit.autoCloseBrackets"; // EditorOptionHandlers.js _getToggler() exports.SHOW_CODE_HINTS = "edit.showCodeHints"; // CodeHintManager.js _startNewSession() - // SEARCH - exports.SEARCH_FIND = "search.find"; // FindReplace.js _launchFind() - exports.SEARCH_FIND_IN_FILES = "search.findInFiles"; // FindInFiles.js _doFindInFiles() - exports.SEARCH_FIND_IN_SELECTED = "search.findInSelected"; // FindInFiles.js _doFindInSubtree() - exports.SEARCH_FIND_IN_SUBTREE = "search.findInSubtree"; // FindInFiles.js _doFindInSubtree() - exports.SEARCH_FIND_NEXT = "search.findNext"; // FindReplace.js _findNext() - exports.SEARCH_FIND_PREVIOUS = "search.findPrevious"; // FindReplace.js _findPrevious() - exports.SEARCH_FIND_ALL_AND_SELECT = "search.findAllAndSelect"; // FindReplace.js _findAllAndSelect() - exports.SEARCH_ADD_NEXT_MATCH = "search.addNextMatch"; // FindReplace.js _expandAndAddNextToSelection() - exports.SEARCH_SKIP_CURRENT_MATCH = "search.skipCurrentMatch"; // FindReplace.js _skipCurrentMatch() - exports.SEARCH_REPLACE = "search.replace"; // FindReplace.js _replace() + // FIND + exports.CMD_FIND = "cmd.find"; // FindReplace.js _launchFind() + exports.CMD_FIND_IN_FILES = "cmd.findInFiles"; // FindInFiles.js _doFindInFiles() + exports.CMD_FIND_IN_SELECTED = "cmd.findInSelected"; // FindInFiles.js _doFindInSubtree() + exports.CMD_FIND_IN_SUBTREE = "cmd.findInSubtree"; // FindInFiles.js _doFindInSubtree() + exports.CMD_FIND_NEXT = "cmd.findNext"; // FindReplace.js _findNext() + exports.CMD_FIND_PREVIOUS = "cmd.findPrevious"; // FindReplace.js _findPrevious() + exports.CMD_FIND_ALL_AND_SELECT = "cmd.findAllAndSelect"; // FindReplace.js _findAllAndSelect() + exports.CMD_ADD_NEXT_MATCH = "cmd.addNextMatch"; // FindReplace.js _expandAndAddNextToSelection() + exports.CMD_SKIP_CURRENT_MATCH = "cmd.skipCurrentMatch"; // FindReplace.js _skipCurrentMatch() + exports.CMD_REPLACE = "cmd.replace"; // FindReplace.js _replace() // VIEW exports.VIEW_HIDE_SIDEBAR = "view.hideSidebar"; // SidebarView.js toggle() diff --git a/src/command/DefaultMenus.js b/src/command/DefaultMenus.js index 105253b36a3..3c5b55c09ed 100644 --- a/src/command/DefaultMenus.js +++ b/src/command/DefaultMenus.js @@ -97,20 +97,20 @@ define(function (require, exports, module) { menu.addMenuItem(Commands.TOGGLE_CLOSE_BRACKETS); /* - * Search menu + * Find 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.addMenuItem(Commands.SEARCH_FIND_ALL_AND_SELECT); - menu.addMenuItem(Commands.SEARCH_ADD_NEXT_MATCH); - menu.addMenuItem(Commands.SEARCH_SKIP_CURRENT_MATCH); + menu = Menus.addMenu(Strings.FIND_MENU, Menus.AppMenuBar.FIND_MENU); + menu.addMenuItem(Commands.CMD_FIND); + menu.addMenuItem(Commands.CMD_FIND_NEXT); + menu.addMenuItem(Commands.CMD_FIND_PREVIOUS); + menu.addMenuItem(Commands.CMD_FIND_ALL_AND_SELECT); + menu.addMenuItem(Commands.CMD_ADD_NEXT_MATCH); + menu.addMenuItem(Commands.CMD_SKIP_CURRENT_MATCH); menu.addMenuDivider(); - menu.addMenuItem(Commands.SEARCH_FIND_IN_FILES); - menu.addMenuItem(Commands.SEARCH_FIND_IN_SELECTED); + menu.addMenuItem(Commands.CMD_FIND_IN_FILES); + menu.addMenuItem(Commands.CMD_FIND_IN_SELECTED); menu.addMenuDivider(); - menu.addMenuItem(Commands.SEARCH_REPLACE); + menu.addMenuItem(Commands.CMD_REPLACE); /* * View menu @@ -204,7 +204,7 @@ define(function (require, exports, module) { project_cmenu.addMenuItem(Commands.FILE_DELETE); project_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_OS); project_cmenu.addMenuDivider(); - project_cmenu.addMenuItem(Commands.SEARCH_FIND_IN_SUBTREE); + project_cmenu.addMenuItem(Commands.CMD_FIND_IN_SUBTREE); project_cmenu.addMenuDivider(); project_cmenu.addMenuItem(Commands.FILE_REFRESH); @@ -215,7 +215,7 @@ define(function (require, exports, module) { working_set_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_FILE_TREE); working_set_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_OS); working_set_cmenu.addMenuDivider(); - working_set_cmenu.addMenuItem(Commands.SEARCH_FIND_IN_SUBTREE); + working_set_cmenu.addMenuItem(Commands.CMD_FIND_IN_SUBTREE); working_set_cmenu.addMenuDivider(); working_set_cmenu.addMenuItem(Commands.FILE_CLOSE); diff --git a/src/command/Menus.js b/src/command/Menus.js index 36e07abfa6f..7239207235b 100644 --- a/src/command/Menus.js +++ b/src/command/Menus.js @@ -46,7 +46,7 @@ define(function (require, exports, module) { var AppMenuBar = { FILE_MENU : "file-menu", EDIT_MENU : "edit-menu", - SEARCH_MENU : "search-menu", + FIND_MENU : "find-menu", VIEW_MENU : "view-menu", NAVIGATE_MENU : "navigate-menu", HELP_MENU : "help-menu" @@ -91,9 +91,9 @@ define(function (require, exports, module) { EDIT_CODE_HINTS_COMMANDS: {sectionMarker: Commands.SHOW_CODE_HINTS}, EDIT_TOGGLE_OPTIONS: {sectionMarker: Commands.TOGGLE_CLOSE_BRACKETS}, - SEARCH_FIND_COMMANDS: {sectionMarker: Commands.SEARCH_FIND}, - SEARCH_FIND_IN_COMMANDS: {sectionMarker: Commands.SEARCH_FIND_IN_FILES}, - SEARCH_REPLACE_COMMANDS: {sectionMarker: Commands.SEARCH_REPLACE}, + FIND_FIND_COMMANDS: {sectionMarker: Commands.CMD_FIND}, + FIND_FIND_IN_COMMANDS: {sectionMarker: Commands.CMD_FIND_IN_FILES}, + FIND_REPLACE_COMMANDS: {sectionMarker: Commands.CMD_REPLACE}, VIEW_HIDESHOW_COMMANDS: {sectionMarker: Commands.VIEW_HIDE_SIDEBAR}, VIEW_FONTSIZE_COMMANDS: {sectionMarker: Commands.VIEW_INCREASE_FONT_SIZE}, diff --git a/src/nls/root/strings.js b/src/nls/root/strings.js index 8d30ce8b3f6..f1b9bdab555 100644 --- a/src/nls/root/strings.js +++ b/src/nls/root/strings.js @@ -303,7 +303,7 @@ define({ "CMD_SHOW_CODE_HINTS" : "Show Code Hints", // Search menu commands - "SEARCH_MENU" : "Search", + "FIND_MENU" : "Find", "CMD_FIND" : "Find", "CMD_FIND_FIELD_PLACEHOLDER" : "Find\u2026", "CMD_FIND_NEXT" : "Find Next", diff --git a/src/search/FindInFiles.js b/src/search/FindInFiles.js index 21288754435..89d1038242c 100644 --- a/src/search/FindInFiles.js +++ b/src/search/FindInFiles.js @@ -1042,7 +1042,7 @@ define(function (require, exports, module) { if (scope instanceof InMemoryFile) { CommandManager.execute(Commands.FILE_OPEN, { fullPath: scope.fullPath }).done(function () { - CommandManager.execute(Commands.SEARCH_FIND); + CommandManager.execute(Commands.CMD_FIND); }); return; } @@ -1237,9 +1237,9 @@ define(function (require, exports, module) { }); // Initialize: command handlers - CommandManager.register(Strings.CMD_FIND_IN_FILES, Commands.SEARCH_FIND_IN_FILES, _doFindInFiles); - CommandManager.register(Strings.CMD_FIND_IN_SELECTED, Commands.SEARCH_FIND_IN_SELECTED, _doFindInSubtree); - CommandManager.register(Strings.CMD_FIND_IN_SUBTREE, Commands.SEARCH_FIND_IN_SUBTREE, _doFindInSubtree); + CommandManager.register(Strings.CMD_FIND_IN_FILES, Commands.CMD_FIND_IN_FILES, _doFindInFiles); + CommandManager.register(Strings.CMD_FIND_IN_SELECTED, Commands.CMD_FIND_IN_SELECTED, _doFindInSubtree); + CommandManager.register(Strings.CMD_FIND_IN_SUBTREE, Commands.CMD_FIND_IN_SUBTREE, _doFindInSubtree); // For unit testing - updated in _doSearch() when search complete exports._searchResults = null; diff --git a/src/search/FindReplace.js b/src/search/FindReplace.js index 3b97782ac2b..710f69288e9 100644 --- a/src/search/FindReplace.js +++ b/src/search/FindReplace.js @@ -602,8 +602,8 @@ define(function (require, exports, module) { // Create the search bar UI (closing any previous modalBar in the process) var htmlContent = Mustache.render(searchBarTemplate, $.extend(templateVars, Strings)); createModalBar(htmlContent); - addShortcutToTooltip($("#find-next"), Commands.SEARCH_FIND_NEXT); - addShortcutToTooltip($("#find-prev"), Commands.SEARCH_FIND_PREVIOUS); + addShortcutToTooltip($("#find-next"), Commands.CMD_FIND_NEXT); + addShortcutToTooltip($("#find-prev"), Commands.CMD_FIND_PREVIOUS); $(modalBar).on("close", function (e, query) { // Clear highlights but leave search state in place so Find Next/Previous work after closing @@ -813,7 +813,7 @@ define(function (require, exports, module) { } openSearchBar(editor, {replace: true}); - addShortcutToTooltip($("#replace-yes"), Commands.SEARCH_REPLACE); + addShortcutToTooltip($("#replace-yes"), Commands.CMD_REPLACE); var cm = editor._codeMirror, state = getSearchState(cm); @@ -912,13 +912,13 @@ define(function (require, exports, module) { $(DocumentManager).on("currentDocumentChange", _handleDocumentChange); - CommandManager.register(Strings.CMD_FIND, Commands.SEARCH_FIND, _launchFind); - CommandManager.register(Strings.CMD_FIND_NEXT, Commands.SEARCH_FIND_NEXT, _findNext); - CommandManager.register(Strings.CMD_REPLACE, Commands.SEARCH_REPLACE, _replace); - CommandManager.register(Strings.CMD_FIND_PREVIOUS, Commands.SEARCH_FIND_PREVIOUS, _findPrevious); - CommandManager.register(Strings.CMD_FIND_ALL_AND_SELECT, Commands.SEARCH_FIND_ALL_AND_SELECT, _findAllAndSelect); - CommandManager.register(Strings.CMD_ADD_NEXT_MATCH, Commands.SEARCH_ADD_NEXT_MATCH, _expandWordAndAddNextToSelection); - CommandManager.register(Strings.CMD_SKIP_CURRENT_MATCH, Commands.SEARCH_SKIP_CURRENT_MATCH, _skipCurrentMatch); + CommandManager.register(Strings.CMD_FIND, Commands.CMD_FIND, _launchFind); + CommandManager.register(Strings.CMD_FIND_NEXT, Commands.CMD_FIND_NEXT, _findNext); + CommandManager.register(Strings.CMD_REPLACE, Commands.CMD_REPLACE, _replace); + CommandManager.register(Strings.CMD_FIND_PREVIOUS, Commands.CMD_FIND_PREVIOUS, _findPrevious); + CommandManager.register(Strings.CMD_FIND_ALL_AND_SELECT, Commands.CMD_FIND_ALL_AND_SELECT, _findAllAndSelect); + CommandManager.register(Strings.CMD_ADD_NEXT_MATCH, Commands.CMD_ADD_NEXT_MATCH, _expandWordAndAddNextToSelection); + CommandManager.register(Strings.CMD_SKIP_CURRENT_MATCH, Commands.CMD_SKIP_CURRENT_MATCH, _skipCurrentMatch); // APIs shared with FindInFiles exports._updatePrefsFromSearchBar = _updatePrefsFromSearchBar; diff --git a/test/spec/FileFilters-test.js b/test/spec/FileFilters-test.js index 6f21d3680bf..bbaf08edcee 100644 --- a/test/spec/FileFilters-test.js +++ b/test/spec/FileFilters-test.js @@ -463,7 +463,7 @@ define(function (require, exports, module) { }, "search bar close"); }); runs(function () { - waitsForDone(CommandManager.execute(Commands.SEARCH_FIND_IN_FILES)); + waitsForDone(CommandManager.execute(Commands.CMD_FIND_IN_FILES)); }); } diff --git a/test/spec/FindReplace-test.js b/test/spec/FindReplace-test.js index 00c0f3177aa..4e6866fd29e 100644 --- a/test/spec/FindReplace-test.js +++ b/test/spec/FindReplace-test.js @@ -358,7 +358,7 @@ define(function (require, exports, module) { var i; for (i = 0; i < selections.length; i++) { expectSelection(selections[i]); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); } // next find should wraparound @@ -484,24 +484,24 @@ define(function (require, exports, module) { it("should find all case-insensitive matches with lowercase text", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); enterSearchText("foo"); expectHighlightedMatches(fooExpectedMatches); expectSelection(fooExpectedMatches[0]); expect(myEditor.centerOnCursor.calls.length).toEqual(1); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(fooExpectedMatches[1]); expect(myEditor.centerOnCursor.calls.length).toEqual(2); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(fooExpectedMatches[2]); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(fooExpectedMatches[3]); expectHighlightedMatches(fooExpectedMatches); // no change in highlights // wraparound - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(fooExpectedMatches[0]); expect(myEditor.centerOnCursor.calls.length).toEqual(5); }); @@ -509,24 +509,24 @@ define(function (require, exports, module) { it("should find all case-insensitive matches with mixed-case text", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); enterSearchText("Foo"); expectHighlightedMatches(fooExpectedMatches); expectSelection(fooExpectedMatches[0]); expect(myEditor.centerOnCursor.calls.length).toEqual(1); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(fooExpectedMatches[1]); expect(myEditor.centerOnCursor.calls.length).toEqual(2); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(fooExpectedMatches[2]); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(fooExpectedMatches[3]); expectHighlightedMatches(fooExpectedMatches); // no change in highlights // wraparound - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(fooExpectedMatches[0]); expect(myEditor.centerOnCursor.calls.length).toEqual(5); }); @@ -534,28 +534,28 @@ define(function (require, exports, module) { it("should find all case-sensitive matches with mixed-case text", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); toggleCaseSensitive(true); enterSearchText("Foo"); expectHighlightedMatches(capitalFooSelections); expectSelection(capitalFooSelections[0]); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(capitalFooSelections[1]); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(capitalFooSelections[2]); // note the lowercase "foo()" is NOT matched // wraparound - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(capitalFooSelections[0]); }); it("toggling case-sensitive option should update results immediately", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); enterSearchText("Foo"); expectHighlightedMatches(fooExpectedMatches); @@ -565,7 +565,7 @@ define(function (require, exports, module) { expectHighlightedMatches(capitalFooSelections); expectSelection(capitalFooSelections[0]); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(capitalFooSelections[1]); }); @@ -574,7 +574,7 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); enterSearchText("foo"); pressEscape(); @@ -588,16 +588,16 @@ define(function (require, exports, module) { expect(myEditor.centerOnCursor.calls.length).toEqual(1); // Simple linear Find Next - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: 31}, end: {line: LINE_FIRST_REQUIRE, ch: 34}}); expect(myEditor.centerOnCursor.calls.length).toEqual(2); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection({start: {line: 6, ch: 17}, end: {line: 6, ch: 20}}); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection({start: {line: 8, ch: 8}, end: {line: 8, ch: 11}}); // Wrap around to first result - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: 8}, end: {line: LINE_FIRST_REQUIRE, ch: 11}}); }); }); @@ -606,7 +606,7 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); enterSearchText("foo"); pressEscape(); @@ -618,15 +618,15 @@ define(function (require, exports, module) { expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: 8}, end: {line: LINE_FIRST_REQUIRE, ch: 11}}); // Wrap around to last result - twCommandManager.execute(Commands.SEARCH_FIND_PREVIOUS); + twCommandManager.execute(Commands.CMD_FIND_PREVIOUS); expectSelection({start: {line: 8, ch: 8}, end: {line: 8, ch: 11}}); // Simple linear Find Previous - twCommandManager.execute(Commands.SEARCH_FIND_PREVIOUS); + twCommandManager.execute(Commands.CMD_FIND_PREVIOUS); expectSelection({start: {line: 6, ch: 17}, end: {line: 6, ch: 20}}); - twCommandManager.execute(Commands.SEARCH_FIND_PREVIOUS); + twCommandManager.execute(Commands.CMD_FIND_PREVIOUS); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: 31}, end: {line: LINE_FIRST_REQUIRE, ch: 34}}); - twCommandManager.execute(Commands.SEARCH_FIND_PREVIOUS); + twCommandManager.execute(Commands.CMD_FIND_PREVIOUS); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: 8}, end: {line: LINE_FIRST_REQUIRE, ch: 11}}); }); }); @@ -635,7 +635,7 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); enterSearchText("foo"); pressEscape(); @@ -647,19 +647,19 @@ define(function (require, exports, module) { runs(function () { expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: 8}, end: {line: LINE_FIRST_REQUIRE, ch: 11}}); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: 31}, end: {line: LINE_FIRST_REQUIRE, ch: 34}}); // skip forward myEditor.setCursorPos(7, 0); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection({start: {line: 8, ch: 8}, end: {line: 8, ch: 11}}); // skip backward myEditor.setCursorPos(LINE_FIRST_REQUIRE, 14); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: 31}, end: {line: LINE_FIRST_REQUIRE, ch: 34}}); }); }); @@ -668,7 +668,7 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); toggleCaseSensitive(true); enterSearchText("Foo"); @@ -687,7 +687,7 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); enterSearchText("foo"); pressEscape(); @@ -698,12 +698,12 @@ define(function (require, exports, module) { runs(function () { // Open search bar a second time myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); expectSearchBarOpen(); expect(myEditor).toHaveCursorPosition(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expect(myEditor).toHaveCursorPosition(0, 0); }); }); @@ -711,7 +711,7 @@ define(function (require, exports, module) { it("should open search bar on Find Next with no previous search", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSearchBarOpen(); expect(myEditor).toHaveCursorPosition(0, 0); @@ -721,7 +721,7 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); enterSearchText("foo"); // position cursor first @@ -732,7 +732,7 @@ define(function (require, exports, module) { expect(myEditor).toHaveCursorPosition(LINE_FIRST_REQUIRE, 11); // cursor left at end of last good match ("foo") // Invoke Find a 2nd time - this time while search bar is open - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); }); waitsForSearchBarReopen(); @@ -753,7 +753,7 @@ define(function (require, exports, module) { it("should re-search from original position when text changes", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); enterSearchText("baz"); @@ -773,14 +773,14 @@ define(function (require, exports, module) { it("should re-search from original position when text changes, even after Find Next", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); enterSearchText("foo"); expectSelection(fooExpectedMatches[0]); // get search highlight down below where the "bar" match will be - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(fooExpectedMatches[2]); enterSearchText("bar"); @@ -790,14 +790,14 @@ define(function (require, exports, module) { it("should get primary selection as initial query", function () { myEditor.setSelections([{start: {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_START}, end: {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_PAREN}, primary: true}, {start: {line: 1, ch: 0}, end: {line: 1, ch: 1}}]); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); expect(getSearchField().val()).toEqual("require"); }); it("should extend original selection when appending to prepopulated text", function () { myEditor.setSelection({line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_START}, {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_PAREN}); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); expect(getSearchField().val()).toEqual("require"); var requireExpectedMatches = [ @@ -821,7 +821,7 @@ define(function (require, exports, module) { it("should collapse selection when appending to prepopulated text causes no result", function () { myEditor.setSelection({line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_START}, {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_PAREN}); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_START}, end: {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_PAREN}}); enterSearchText("requireX"); @@ -832,7 +832,7 @@ define(function (require, exports, module) { it("should clear selection, return cursor to start after backspacing to empty query", function () { myEditor.setCursorPos(2, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); enterSearchText("require"); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_START}, end: {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_PAREN}}); @@ -844,7 +844,7 @@ define(function (require, exports, module) { it("should incremental search & highlight from Replace mode too", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); enterSearchText("baz"); var expectedSelections = [ @@ -869,7 +869,7 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(LINE_FIRST_REQUIRE, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); expect(myEditor).toHaveCursorPosition(LINE_FIRST_REQUIRE, 0); enterSearchText("require"); @@ -889,13 +889,13 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(LINE_FIRST_REQUIRE, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); expect(myEditor).toHaveCursorPosition(LINE_FIRST_REQUIRE, 0); enterSearchText("require"); expectSelection({start: {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_START}, end: {line: LINE_FIRST_REQUIRE, ch: CH_REQUIRE_PAREN}}); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection({start: {line: LINE_FIRST_REQUIRE + 1, ch: CH_REQUIRE_START}, end: {line: LINE_FIRST_REQUIRE + 1, ch: CH_REQUIRE_PAREN}}); pressEscape(); @@ -911,10 +911,10 @@ define(function (require, exports, module) { it("should no-op on Find Next with blank search", function () { myEditor.setCursorPos(LINE_FIRST_REQUIRE, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); expect(myEditor).toHaveCursorPosition(LINE_FIRST_REQUIRE, 0); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expect(myEditor).toHaveCursorPosition(LINE_FIRST_REQUIRE, 0); // no change }); @@ -931,7 +931,7 @@ define(function (require, exports, module) { ]; myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); toggleRegexp(true); toggleCaseSensitive(true); @@ -939,15 +939,15 @@ define(function (require, exports, module) { expectHighlightedMatches(expectedSelections); expectSelection(expectedSelections[0]); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(expectedSelections[1]); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(expectedSelections[2]); - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(expectedSelections[3]); // wraparound - twCommandManager.execute(Commands.SEARCH_FIND_NEXT); + twCommandManager.execute(Commands.CMD_FIND_NEXT); expectSelection(expectedSelections[0]); }); @@ -963,7 +963,7 @@ define(function (require, exports, module) { runs(function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); toggleRegexp(true); enterSearchText("Ba."); @@ -977,7 +977,7 @@ define(function (require, exports, module) { expectFindNextSelections(expectedSelections); // explicitly clean up since we closed the search bar - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); toggleRegexp(false); }); }); @@ -985,7 +985,7 @@ define(function (require, exports, module) { it("toggling regexp option should update results immediately", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); enterSearchText("t ."); expectHighlightedMatches([]); @@ -1006,7 +1006,7 @@ define(function (require, exports, module) { ]; myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); toggleRegexp(true); toggleCaseSensitive(true); @@ -1024,7 +1024,7 @@ define(function (require, exports, module) { ]; myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); toggleRegexp(true); toggleCaseSensitive(false); @@ -1036,7 +1036,7 @@ define(function (require, exports, module) { it("shouldn't choke on invalid regexp", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); toggleRegexp(true); enterSearchText("+"); @@ -1048,7 +1048,7 @@ define(function (require, exports, module) { it("shouldn't choke on empty regexp", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); toggleRegexp(true); enterSearchText(""); @@ -1059,7 +1059,7 @@ define(function (require, exports, module) { it("shouldn't freeze on /.*/ regexp", function () { myEditor.setCursorPos(0, 0); - twCommandManager.execute(Commands.SEARCH_FIND); + twCommandManager.execute(Commands.CMD_FIND); toggleRegexp(true); enterSearchText(".*/"); @@ -1071,7 +1071,7 @@ define(function (require, exports, module) { describe("Search -> Replace", function () { it("should find and replace one string", function () { runs(function () { - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); enterSearchText("foo"); expectSelection(fooExpectedMatches[0]); @@ -1090,13 +1090,13 @@ define(function (require, exports, module) { it("should use replace keyboard shortcut for single Replace while search bar open", function () { runs(function () { - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); enterSearchText("foo"); expectSelection(fooExpectedMatches[0]); enterReplaceText("bar"); - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); expectSelection(fooExpectedMatches[1]); myEditor.setSelection(fooExpectedMatches[0].start, fooExpectedMatches[0].end); @@ -1106,7 +1106,7 @@ define(function (require, exports, module) { it("should find and replace a regexp with $n substitutions", function () { runs(function () { - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("$2:$1"); @@ -1126,7 +1126,7 @@ define(function (require, exports, module) { it("should find a regexp and replace it with $0n (leading zero)", function () { runs(function () { - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("$02:$01"); @@ -1146,7 +1146,7 @@ define(function (require, exports, module) { it("should find a regexp and replace it with $0 (literal)", function () { runs(function () { - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("$0_:$01"); @@ -1166,7 +1166,7 @@ define(function (require, exports, module) { it("should find a regexp and replace it with $n (empty subexpression)", function () { runs(function () { - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); toggleRegexp(true); enterSearchText("(modules)(.*)\\/(\\w+)"); enterReplaceText("$3$2:$1"); @@ -1186,7 +1186,7 @@ define(function (require, exports, module) { it("should find a regexp and replace it with $nn (n has two digits)", function () { runs(function () { - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); toggleRegexp(true); enterSearchText("()()()()()()()()()()(modules)\\/()()()(\\w+)"); enterReplaceText("$15:$11"); @@ -1206,7 +1206,7 @@ define(function (require, exports, module) { it("should find a regexp and replace it with $$n (not a subexpression, escaped dollar)", function () { runs(function () { - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("$$2_$$10:$2"); @@ -1226,7 +1226,7 @@ define(function (require, exports, module) { it("should find a regexp and replace it with $$$n (correct subexpression)", function () { runs(function () { - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("$2$$$1"); @@ -1246,7 +1246,7 @@ define(function (require, exports, module) { it("should find a regexp and replace it with $& (whole match)", function () { runs(function () { - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("_$&-$2$$&"); @@ -1269,7 +1269,7 @@ define(function (require, exports, module) { describe("Search -> Replace All", function () { it("should find all regexps and replace them with $n", function () { runs(function () { - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("$2:$1"); @@ -1296,7 +1296,7 @@ define(function (require, exports, module) { it("should find all regexps and replace them with $n (empty subexpression)", function () { runs(function () { - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); toggleRegexp(true); enterSearchText("(modules)(.*)\\/(\\w+)"); enterReplaceText("$3$2:$1"); @@ -1323,7 +1323,7 @@ define(function (require, exports, module) { it("should find all regexps and replace them with $nn (n has two digits)", function () { runs(function () { - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); toggleRegexp(true); enterSearchText("()()()()()()()()()()(modules)\\/()()()(\\w+)"); enterReplaceText("$15:$11"); @@ -1350,7 +1350,7 @@ define(function (require, exports, module) { it("should find all regexps and replace them with $$n (not a subexpression, escaped dollar)", function () { runs(function () { - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("$$2_$$10:$2"); @@ -1377,7 +1377,7 @@ define(function (require, exports, module) { it("should find all regexps and replace them with $$$n (correct subexpression)", function () { runs(function () { - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("$2$$$1"); @@ -1404,7 +1404,7 @@ define(function (require, exports, module) { it("should find all regexps and replace them with $& (whole match)", function () { runs(function () { - twCommandManager.execute(Commands.SEARCH_REPLACE); + twCommandManager.execute(Commands.CMD_REPLACE); toggleRegexp(true); enterSearchText("(modules)\\/(\\w+)"); enterReplaceText("_$&-$2$$&"); From 56ab3e942f5b651da6d91176cd4da8b41a8c7252 Mon Sep 17 00:00:00 2001 From: Lance Campbell Date: Tue, 15 Apr 2014 21:51:39 -0700 Subject: [PATCH 5/8] Add deprecation code --- src/command/Commands.js | 12 ++++++++++++ src/command/Menus.js | 19 ++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/command/Commands.js b/src/command/Commands.js index 88f36243302..08408cd3960 100644 --- a/src/command/Commands.js +++ b/src/command/Commands.js @@ -85,6 +85,18 @@ define(function (require, exports, module) { exports.TOGGLE_CLOSE_BRACKETS = "edit.autoCloseBrackets"; // EditorOptionHandlers.js _getToggler() exports.SHOW_CODE_HINTS = "edit.showCodeHints"; // CodeHintManager.js _startNewSession() + // DEPRECATED: Redirect Edit commands that were moved from the Edit Menu to the Find Menu + exports.EDIT_FIND = "cmd.find"; // FindReplace.js _launchFind() + exports.EDIT_FIND_IN_FILES = "cmd.findInFiles"; // FindInFiles.js _doFindInFiles() + exports.EDIT_FIND_IN_SELECTED = "cmd.findInSelected"; // FindInFiles.js _doFindInSubtree() + exports.EDIT_FIND_IN_SUBTREE = "cmd.findInSubtree"; // FindInFiles.js _doFindInSubtree() + exports.EDIT_FIND_NEXT = "cmd.findNext"; // FindReplace.js _findNext() + exports.EDIT_FIND_PREVIOUS = "cmd.findPrevious"; // FindReplace.js _findPrevious() + exports.EDIT_FIND_ALL_AND_SELECT = "cmd.findAllAndSelect"; // FindReplace.js _findAllAndSelect() + exports.EDIT_ADD_NEXT_MATCH = "cmd.addNextMatch"; // FindReplace.js _expandAndAddNextToSelection() + exports.EDIT_SKIP_CURRENT_MATCH = "cmd.skipCurrentMatch"; // FindReplace.js _skipCurrentMatch() + exports.EDIT_REPLACE = "cmd.replace"; // FindReplace.js _replace() + // FIND exports.CMD_FIND = "cmd.find"; // FindReplace.js _launchFind() exports.CMD_FIND_IN_FILES = "cmd.findInFiles"; // FindInFiles.js _doFindInFiles() diff --git a/src/command/Menus.js b/src/command/Menus.js index 7239207235b..0a79ec02bbe 100644 --- a/src/command/Menus.js +++ b/src/command/Menus.js @@ -37,7 +37,8 @@ define(function (require, exports, module) { StringUtils = require("utils/StringUtils"), CommandManager = require("command/CommandManager"), PopUpManager = require("widgets/PopUpManager"), - ViewUtils = require("utils/ViewUtils"); + ViewUtils = require("utils/ViewUtils"), + DeprecationWarning = require("utils/DeprecationWarning"); /** * Brackets Application Menu Constants @@ -91,6 +92,10 @@ define(function (require, exports, module) { EDIT_CODE_HINTS_COMMANDS: {sectionMarker: Commands.SHOW_CODE_HINTS}, EDIT_TOGGLE_OPTIONS: {sectionMarker: Commands.TOGGLE_CLOSE_BRACKETS}, + // DEPRECATED: Old Edit menu sections redirected to existing Edit menu section + EDIT_FIND_COMMANDS: {sectionMarker: Commands.TOGGLE_CLOSE_BRACKETS}, + EDIT_REPLACE_COMMANDS: {sectionMarker: Commands.TOGGLE_CLOSE_BRACKETS}, + FIND_FIND_COMMANDS: {sectionMarker: Commands.CMD_FIND}, FIND_FIND_IN_COMMANDS: {sectionMarker: Commands.CMD_FIND_IN_FILES}, FIND_REPLACE_COMMANDS: {sectionMarker: Commands.CMD_REPLACE}, @@ -362,7 +367,7 @@ define(function (require, exports, module) { */ Menu.prototype._getRelativeMenuItem = function (relativeID, position) { var $relativeElement; - + if (relativeID) { if (position === FIRST_IN_SECTION || position === LAST_IN_SECTION) { if (!relativeID.hasOwnProperty("sectionMarker")) { @@ -550,7 +555,15 @@ define(function (require, exports, module) { menuItem, name, commandID; - + + if (relativeID === MenuSection.EDIT_FIND_COMMANDS) { + DeprecationWarning.deprecationWarning("Add " + command + " Command to the Find Menu instead of the Edit Menu.", true); + DeprecationWarning.deprecationWarning("Use MenuSection.FIND_FIND_COMMANDS instead of MenuSection.EDIT_FIND_COMMANDS.", true); + } else if (relativeID === MenuSection.EDIT_REPLACE_COMMANDS) { + DeprecationWarning.deprecationWarning("Add " + command + "Command to the Find Menu instead of the Edit Menu.", true); + DeprecationWarning.deprecationWarning("Use MenuSection.FIND_REPLACE_COMMANDS instead of MenuSection.EDIT_REPLACE_COMMANDS.", true); + } + if (!command) { console.error("addMenuItem(): missing required parameters: command"); return null; From 427c8e999d816c850d59d1b6c15d79f693423b69 Mon Sep 17 00:00:00 2001 From: Lance Campbell Date: Thu, 17 Apr 2014 23:30:51 -0700 Subject: [PATCH 6/8] Fix merge conflict --- test/spec/FileFilters-test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/FileFilters-test.js b/test/spec/FileFilters-test.js index bbaf08edcee..4e83dd4ac51 100644 --- a/test/spec/FileFilters-test.js +++ b/test/spec/FileFilters-test.js @@ -463,7 +463,7 @@ define(function (require, exports, module) { }, "search bar close"); }); runs(function () { - waitsForDone(CommandManager.execute(Commands.CMD_FIND_IN_FILES)); + FindInFiles._doFindInFiles(scope); }); } From 7ca5f89f14dbaf957235140c6baa9a5280215a8e Mon Sep 17 00:00:00 2001 From: Lance Campbell Date: Mon, 21 Apr 2014 19:04:58 -0700 Subject: [PATCH 7/8] Update Commands deprecation code --- src/command/Commands.js | 43 +++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/command/Commands.js b/src/command/Commands.js index 08408cd3960..add49d80ea5 100644 --- a/src/command/Commands.js +++ b/src/command/Commands.js @@ -28,6 +28,26 @@ define(function (require, exports, module) { "use strict"; + var DeprecationWarning = require("utils/DeprecationWarning"); + + /** + * @private + * Create a deprecation warning and action for updated Command constants + * @param {!string} oldConstant + * @param {!string} newConstant + */ + function _deprecateCommand(oldConstant, newConstant) { + var warning = "Use Commands." + newConstant + " instead of Commands." + oldConstant + ".", + newValue = exports[newConstant]; + + Object.defineProperty(exports, oldConstant, { + get: function () { + DeprecationWarning.deprecationWarning(warning, true); + return newValue; + } + }); + } + /** * List of constants for global command IDs. */ @@ -85,18 +105,6 @@ define(function (require, exports, module) { exports.TOGGLE_CLOSE_BRACKETS = "edit.autoCloseBrackets"; // EditorOptionHandlers.js _getToggler() exports.SHOW_CODE_HINTS = "edit.showCodeHints"; // CodeHintManager.js _startNewSession() - // DEPRECATED: Redirect Edit commands that were moved from the Edit Menu to the Find Menu - exports.EDIT_FIND = "cmd.find"; // FindReplace.js _launchFind() - exports.EDIT_FIND_IN_FILES = "cmd.findInFiles"; // FindInFiles.js _doFindInFiles() - exports.EDIT_FIND_IN_SELECTED = "cmd.findInSelected"; // FindInFiles.js _doFindInSubtree() - exports.EDIT_FIND_IN_SUBTREE = "cmd.findInSubtree"; // FindInFiles.js _doFindInSubtree() - exports.EDIT_FIND_NEXT = "cmd.findNext"; // FindReplace.js _findNext() - exports.EDIT_FIND_PREVIOUS = "cmd.findPrevious"; // FindReplace.js _findPrevious() - exports.EDIT_FIND_ALL_AND_SELECT = "cmd.findAllAndSelect"; // FindReplace.js _findAllAndSelect() - exports.EDIT_ADD_NEXT_MATCH = "cmd.addNextMatch"; // FindReplace.js _expandAndAddNextToSelection() - exports.EDIT_SKIP_CURRENT_MATCH = "cmd.skipCurrentMatch"; // FindReplace.js _skipCurrentMatch() - exports.EDIT_REPLACE = "cmd.replace"; // FindReplace.js _replace() - // FIND exports.CMD_FIND = "cmd.find"; // FindReplace.js _launchFind() exports.CMD_FIND_IN_FILES = "cmd.findInFiles"; // FindInFiles.js _doFindInFiles() @@ -161,5 +169,16 @@ define(function (require, exports, module) { // File shell callbacks - string must MATCH string in native code (appshell/command_callbacks.h) exports.APP_ABORT_QUIT = "app.abort_quit"; // DocumentCommandHandlers.js handleAbortQuit() exports.APP_BEFORE_MENUPOPUP = "app.before_menupopup"; // DocumentCommandHandlers.js handleBeforeMenuPopup() + + // DEPRECATED: Edit commands that were moved from the Edit Menu to the Find Menu + _deprecateCommand("EDIT_FIND", "CMD_FIND"); + _deprecateCommand("EDIT_FIND_IN_SELECTED", "CMD_FIND_IN_SELECTED"); + _deprecateCommand("EDIT_FIND_IN_SUBTREE", "CMD_FIND_IN_SUBTREE"); + _deprecateCommand("EDIT_FIND_NEXT", "CMD_FIND_NEXT"); + _deprecateCommand("EDIT_FIND_PREVIOUS", "CMD_FIND_PREVIOUS"); + _deprecateCommand("EDIT_FIND_ALL_AND_SELECT", "CMD_FIND_ALL_AND_SELECT"); + _deprecateCommand("EDIT_ADD_NEXT_MATCH", "CMD_ADD_NEXT_MATCH"); + _deprecateCommand("EDIT_SKIP_CURRENT_MATCH", "CMD_SKIP_CURRENT_MATCH"); + _deprecateCommand("EDIT_REPLACE", "CMD_REPLACE"); }); From 4c633af100d266ab5d93dc6e6d329ba18e9080e2 Mon Sep 17 00:00:00 2001 From: Lance Campbell Date: Wed, 23 Apr 2014 18:11:16 -0700 Subject: [PATCH 8/8] Small Code clean up --- src/command/Commands.js | 2 +- src/command/Menus.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/command/Commands.js b/src/command/Commands.js index add49d80ea5..c35f0f5a30b 100644 --- a/src/command/Commands.js +++ b/src/command/Commands.js @@ -37,7 +37,7 @@ define(function (require, exports, module) { * @param {!string} newConstant */ function _deprecateCommand(oldConstant, newConstant) { - var warning = "Use Commands." + newConstant + " instead of Commands." + oldConstant + ".", + var warning = "Use Commands." + newConstant + " instead of Commands." + oldConstant, newValue = exports[newConstant]; Object.defineProperty(exports, oldConstant, { diff --git a/src/command/Menus.js b/src/command/Menus.js index 0a79ec02bbe..77a5a5aeb1e 100644 --- a/src/command/Menus.js +++ b/src/command/Menus.js @@ -560,7 +560,7 @@ define(function (require, exports, module) { DeprecationWarning.deprecationWarning("Add " + command + " Command to the Find Menu instead of the Edit Menu.", true); DeprecationWarning.deprecationWarning("Use MenuSection.FIND_FIND_COMMANDS instead of MenuSection.EDIT_FIND_COMMANDS.", true); } else if (relativeID === MenuSection.EDIT_REPLACE_COMMANDS) { - DeprecationWarning.deprecationWarning("Add " + command + "Command to the Find Menu instead of the Edit Menu.", true); + DeprecationWarning.deprecationWarning("Add " + command + " Command to the Find Menu instead of the Edit Menu.", true); DeprecationWarning.deprecationWarning("Use MenuSection.FIND_REPLACE_COMMANDS instead of MenuSection.EDIT_REPLACE_COMMANDS.", true); }