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

Commit 4d968b2

Browse files
author
Narciso Jaramillo
committed
Merge pull request #7488 from lkcampbell/fix-6084
Fix for issue #6084: Move Find items to different menu
2 parents e3bc31c + 4c633af commit 4d968b2

8 files changed

Lines changed: 252 additions & 192 deletions

File tree

src/base-config/keyboard.json

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -80,58 +80,6 @@
8080
"displayKey": "Shift-Alt-↓"
8181
}
8282
],
83-
"edit.find": [
84-
"Ctrl-F"
85-
],
86-
"edit.findInFiles": [
87-
"Ctrl-Shift-F"
88-
],
89-
"edit.findNext": [
90-
{
91-
"key": "F3"
92-
},
93-
{
94-
"key": "Cmd-G",
95-
"platform": "mac"
96-
}
97-
],
98-
"edit.findPrevious": [
99-
{
100-
"key": "Shift-F3"
101-
},
102-
{
103-
"key": "Cmd-Shift-G",
104-
"platform": "mac"
105-
}
106-
],
107-
"edit.findAllAndSelect": [
108-
{
109-
"key": "Alt-F3"
110-
},
111-
{
112-
"key": "Cmd-Ctrl-G",
113-
"platform": "mac"
114-
}
115-
],
116-
"edit.addNextMatch": [
117-
{
118-
"key": "Ctrl-B"
119-
}
120-
],
121-
"edit.skipCurrentMatch": [
122-
{
123-
"key": "Ctrl-Shift-B"
124-
}
125-
],
126-
"edit.replace": [
127-
{
128-
"key": "Ctrl-H"
129-
},
130-
{
131-
"key": "Cmd-Alt-F",
132-
"platform": "mac"
133-
}
134-
],
13583
"edit.indent": [
13684
{
13785
"key": "Ctrl-]"
@@ -197,6 +145,58 @@
197145
"platform": "mac"
198146
}
199147
],
148+
"cmd.find": [
149+
"Ctrl-F"
150+
],
151+
"cmd.findInFiles": [
152+
"Ctrl-Shift-F"
153+
],
154+
"cmd.findNext": [
155+
{
156+
"key": "F3"
157+
},
158+
{
159+
"key": "Cmd-G",
160+
"platform": "mac"
161+
}
162+
],
163+
"cmd.findPrevious": [
164+
{
165+
"key": "Shift-F3"
166+
},
167+
{
168+
"key": "Cmd-Shift-G",
169+
"platform": "mac"
170+
}
171+
],
172+
"cmd.findAllAndSelect": [
173+
{
174+
"key": "Alt-F3"
175+
},
176+
{
177+
"key": "Cmd-Ctrl-G",
178+
"platform": "mac"
179+
}
180+
],
181+
"cmd.addNextMatch": [
182+
{
183+
"key": "Ctrl-B"
184+
}
185+
],
186+
"cmd.skipCurrentMatch": [
187+
{
188+
"key": "Ctrl-Shift-B"
189+
}
190+
],
191+
"cmd.replace": [
192+
{
193+
"key": "Ctrl-H"
194+
},
195+
{
196+
"key": "Cmd-Alt-F",
197+
"platform": "mac"
198+
}
199+
],
200200
"view.hideSidebar": [
201201
"Ctrl-Shift-H"
202202
],

src/command/Commands.js

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,30 @@
2828
define(function (require, exports, module) {
2929
"use strict";
3030

31+
var DeprecationWarning = require("utils/DeprecationWarning");
32+
33+
/**
34+
* @private
35+
* Create a deprecation warning and action for updated Command constants
36+
* @param {!string} oldConstant
37+
* @param {!string} newConstant
38+
*/
39+
function _deprecateCommand(oldConstant, newConstant) {
40+
var warning = "Use Commands." + newConstant + " instead of Commands." + oldConstant,
41+
newValue = exports[newConstant];
42+
43+
Object.defineProperty(exports, oldConstant, {
44+
get: function () {
45+
DeprecationWarning.deprecationWarning(warning, true);
46+
return newValue;
47+
}
48+
});
49+
}
50+
3151
/**
3252
* List of constants for global command IDs.
3353
*/
34-
54+
3555
// FILE
3656
exports.FILE_NEW_UNTITLED = "file.newDoc"; // DocumentCommandHandlers.js handleFileNew()
3757
exports.FILE_NEW = "file.newFile"; // DocumentCommandHandlers.js handleFileNewInProject()
@@ -72,15 +92,6 @@ define(function (require, exports, module) {
7292
exports.EDIT_SPLIT_SEL_INTO_LINES = "edit.splitSelIntoLines"; // EditorCommandHandlers.js splitSelIntoLines()
7393
exports.EDIT_ADD_CUR_TO_NEXT_LINE = "edit.addCursorToNextLine"; // EditorCommandHandlers.js addCursorToNextLine()
7494
exports.EDIT_ADD_CUR_TO_PREV_LINE = "edit.addCursorToPrevLine"; // EditorCommandHandlers.js addCursorToPrevLine()
75-
exports.EDIT_FIND = "edit.find"; // FindReplace.js _launchFind()
76-
exports.EDIT_FIND_IN_FILES = "edit.findInFiles"; // FindInFiles.js _doFindInFiles()
77-
exports.EDIT_FIND_IN_SUBTREE = "edit.findInSubtree"; // FindInFiles.js _doFindInSubtree()
78-
exports.EDIT_FIND_NEXT = "edit.findNext"; // FindReplace.js _findNext()
79-
exports.EDIT_FIND_PREVIOUS = "edit.findPrevious"; // FindReplace.js _findPrevious()
80-
exports.EDIT_FIND_ALL_AND_SELECT = "edit.findAllAndSelect"; // FindReplace.js _findAllAndSelect()
81-
exports.EDIT_ADD_NEXT_MATCH = "edit.addNextMatch"; // FindReplace.js _expandAndAddNextToSelection()
82-
exports.EDIT_SKIP_CURRENT_MATCH = "edit.skipCurrentMatch"; // FindReplace.js _skipCurrentMatch()
83-
exports.EDIT_REPLACE = "edit.replace"; // FindReplace.js _replace()
8495
exports.EDIT_INDENT = "edit.indent"; // EditorCommandHandlers.js indentText()
8596
exports.EDIT_UNINDENT = "edit.unindent"; // EditorCommandHandlers.js unindentText()
8697
exports.EDIT_DUPLICATE = "edit.duplicate"; // EditorCommandHandlers.js duplicateText()
@@ -93,7 +104,19 @@ define(function (require, exports, module) {
93104
exports.EDIT_OPEN_LINE_BELOW = "edit.openLineBelow"; // EditorCommandHandlers.js openLineBelow()
94105
exports.TOGGLE_CLOSE_BRACKETS = "edit.autoCloseBrackets"; // EditorOptionHandlers.js _getToggler()
95106
exports.SHOW_CODE_HINTS = "edit.showCodeHints"; // CodeHintManager.js _startNewSession()
96-
107+
108+
// FIND
109+
exports.CMD_FIND = "cmd.find"; // FindReplace.js _launchFind()
110+
exports.CMD_FIND_IN_FILES = "cmd.findInFiles"; // FindInFiles.js _doFindInFiles()
111+
exports.CMD_FIND_IN_SELECTED = "cmd.findInSelected"; // FindInFiles.js _doFindInSubtree()
112+
exports.CMD_FIND_IN_SUBTREE = "cmd.findInSubtree"; // FindInFiles.js _doFindInSubtree()
113+
exports.CMD_FIND_NEXT = "cmd.findNext"; // FindReplace.js _findNext()
114+
exports.CMD_FIND_PREVIOUS = "cmd.findPrevious"; // FindReplace.js _findPrevious()
115+
exports.CMD_FIND_ALL_AND_SELECT = "cmd.findAllAndSelect"; // FindReplace.js _findAllAndSelect()
116+
exports.CMD_ADD_NEXT_MATCH = "cmd.addNextMatch"; // FindReplace.js _expandAndAddNextToSelection()
117+
exports.CMD_SKIP_CURRENT_MATCH = "cmd.skipCurrentMatch"; // FindReplace.js _skipCurrentMatch()
118+
exports.CMD_REPLACE = "cmd.replace"; // FindReplace.js _replace()
119+
97120
// VIEW
98121
exports.VIEW_HIDE_SIDEBAR = "view.hideSidebar"; // SidebarView.js toggle()
99122
exports.VIEW_INCREASE_FONT_SIZE = "view.increaseFontSize"; // ViewCommandHandlers.js _handleIncreaseFontSize()
@@ -125,7 +148,7 @@ define(function (require, exports, module) {
125148
exports.QUICK_EDIT_NEXT_MATCH = "navigate.nextMatch"; // MultiRangeInlineEditor.js _nextRange()
126149
exports.QUICK_EDIT_PREV_MATCH = "navigate.previousMatch"; // MultiRangeInlineEditor.js _previousRange()
127150
exports.CSS_QUICK_EDIT_NEW_RULE = "navigate.newRule"; // CSSInlineEditor.js _handleNewRule()
128-
151+
129152
// HELP
130153
exports.HELP_CHECK_FOR_UPDATE = "help.checkForUpdate"; // HelpCommandHandlers.js _handleCheckForUpdates()
131154
exports.HELP_HOW_TO_USE_BRACKETS = "help.howToUseBrackets"; // HelpCommandHandlers.js _handleLinkMenuItem()
@@ -138,13 +161,24 @@ define(function (require, exports, module) {
138161

139162
// File shell callbacks - string must MATCH string in native code (appshell/command_callbacks.h)
140163
exports.HELP_ABOUT = "help.about"; // HelpCommandHandlers.js _handleAboutDialog()
141-
164+
142165
// APP
143166
exports.APP_RELOAD = "app.reload"; // DocumentCommandHandlers.js handleReload()
144167
exports.APP_RELOAD_WITHOUT_EXTS = "app.reload_without_exts"; // DocumentCommandHandlers.js handleReloadWithoutExts()
145168

146169
// File shell callbacks - string must MATCH string in native code (appshell/command_callbacks.h)
147170
exports.APP_ABORT_QUIT = "app.abort_quit"; // DocumentCommandHandlers.js handleAbortQuit()
148171
exports.APP_BEFORE_MENUPOPUP = "app.before_menupopup"; // DocumentCommandHandlers.js handleBeforeMenuPopup()
172+
173+
// DEPRECATED: Edit commands that were moved from the Edit Menu to the Find Menu
174+
_deprecateCommand("EDIT_FIND", "CMD_FIND");
175+
_deprecateCommand("EDIT_FIND_IN_SELECTED", "CMD_FIND_IN_SELECTED");
176+
_deprecateCommand("EDIT_FIND_IN_SUBTREE", "CMD_FIND_IN_SUBTREE");
177+
_deprecateCommand("EDIT_FIND_NEXT", "CMD_FIND_NEXT");
178+
_deprecateCommand("EDIT_FIND_PREVIOUS", "CMD_FIND_PREVIOUS");
179+
_deprecateCommand("EDIT_FIND_ALL_AND_SELECT", "CMD_FIND_ALL_AND_SELECT");
180+
_deprecateCommand("EDIT_ADD_NEXT_MATCH", "CMD_ADD_NEXT_MATCH");
181+
_deprecateCommand("EDIT_SKIP_CURRENT_MATCH", "CMD_SKIP_CURRENT_MATCH");
182+
_deprecateCommand("EDIT_REPLACE", "CMD_REPLACE");
149183
});
150184

src/command/DefaultMenus.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ define(function (require, exports, module) {
6464
menu.addMenuDivider();
6565
menu.addMenuItem(Commands.FILE_QUIT);
6666
}
67-
67+
6868
/*
6969
* Edit menu
7070
*/
@@ -82,17 +82,6 @@ define(function (require, exports, module) {
8282
menu.addMenuItem(Commands.EDIT_ADD_CUR_TO_PREV_LINE);
8383
menu.addMenuItem(Commands.EDIT_ADD_CUR_TO_NEXT_LINE);
8484
menu.addMenuDivider();
85-
menu.addMenuItem(Commands.EDIT_FIND);
86-
menu.addMenuItem(Commands.EDIT_FIND_IN_FILES);
87-
menu.addMenuItem(Commands.EDIT_FIND_NEXT);
88-
menu.addMenuItem(Commands.EDIT_FIND_PREVIOUS);
89-
menu.addMenuItem(Commands.EDIT_FIND_ALL_AND_SELECT);
90-
menu.addMenuItem(Commands.EDIT_ADD_NEXT_MATCH);
91-
menu.addMenuItem(Commands.EDIT_SKIP_CURRENT_MATCH);
92-
93-
menu.addMenuDivider();
94-
menu.addMenuItem(Commands.EDIT_REPLACE);
95-
menu.addMenuDivider();
9685
menu.addMenuItem(Commands.EDIT_INDENT);
9786
menu.addMenuItem(Commands.EDIT_UNINDENT);
9887
menu.addMenuItem(Commands.EDIT_DUPLICATE);
@@ -106,7 +95,23 @@ define(function (require, exports, module) {
10695
menu.addMenuItem(Commands.SHOW_CODE_HINTS);
10796
menu.addMenuDivider();
10897
menu.addMenuItem(Commands.TOGGLE_CLOSE_BRACKETS);
109-
98+
99+
/*
100+
* Find menu
101+
*/
102+
menu = Menus.addMenu(Strings.FIND_MENU, Menus.AppMenuBar.FIND_MENU);
103+
menu.addMenuItem(Commands.CMD_FIND);
104+
menu.addMenuItem(Commands.CMD_FIND_NEXT);
105+
menu.addMenuItem(Commands.CMD_FIND_PREVIOUS);
106+
menu.addMenuItem(Commands.CMD_FIND_ALL_AND_SELECT);
107+
menu.addMenuItem(Commands.CMD_ADD_NEXT_MATCH);
108+
menu.addMenuItem(Commands.CMD_SKIP_CURRENT_MATCH);
109+
menu.addMenuDivider();
110+
menu.addMenuItem(Commands.CMD_FIND_IN_FILES);
111+
menu.addMenuItem(Commands.CMD_FIND_IN_SELECTED);
112+
menu.addMenuDivider();
113+
menu.addMenuItem(Commands.CMD_REPLACE);
114+
110115
/*
111116
* View menu
112117
*/
@@ -146,7 +151,7 @@ define(function (require, exports, module) {
146151
menu.addMenuItem(Commands.CSS_QUICK_EDIT_NEW_RULE);
147152
menu.addMenuDivider();
148153
menu.addMenuItem(Commands.TOGGLE_QUICK_DOCS);
149-
154+
150155
/*
151156
* Help menu
152157
*/
@@ -199,7 +204,7 @@ define(function (require, exports, module) {
199204
project_cmenu.addMenuItem(Commands.FILE_DELETE);
200205
project_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_OS);
201206
project_cmenu.addMenuDivider();
202-
project_cmenu.addMenuItem(Commands.EDIT_FIND_IN_SUBTREE);
207+
project_cmenu.addMenuItem(Commands.CMD_FIND_IN_SUBTREE);
203208
project_cmenu.addMenuDivider();
204209
project_cmenu.addMenuItem(Commands.FILE_REFRESH);
205210

@@ -210,7 +215,7 @@ define(function (require, exports, module) {
210215
working_set_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_FILE_TREE);
211216
working_set_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_OS);
212217
working_set_cmenu.addMenuDivider();
213-
working_set_cmenu.addMenuItem(Commands.EDIT_FIND_IN_SUBTREE);
218+
working_set_cmenu.addMenuItem(Commands.CMD_FIND_IN_SUBTREE);
214219
working_set_cmenu.addMenuDivider();
215220
working_set_cmenu.addMenuItem(Commands.FILE_CLOSE);
216221

src/command/Menus.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ define(function (require, exports, module) {
3737
StringUtils = require("utils/StringUtils"),
3838
CommandManager = require("command/CommandManager"),
3939
PopUpManager = require("widgets/PopUpManager"),
40-
ViewUtils = require("utils/ViewUtils");
40+
ViewUtils = require("utils/ViewUtils"),
41+
DeprecationWarning = require("utils/DeprecationWarning");
4142

4243
/**
4344
* Brackets Application Menu Constants
@@ -46,6 +47,7 @@ define(function (require, exports, module) {
4647
var AppMenuBar = {
4748
FILE_MENU : "file-menu",
4849
EDIT_MENU : "edit-menu",
50+
FIND_MENU : "find-menu",
4951
VIEW_MENU : "view-menu",
5052
NAVIGATE_MENU : "navigate-menu",
5153
HELP_MENU : "help-menu"
@@ -85,13 +87,19 @@ define(function (require, exports, module) {
8587
EDIT_UNDO_REDO_COMMANDS: {sectionMarker: Commands.EDIT_UNDO},
8688
EDIT_TEXT_COMMANDS: {sectionMarker: Commands.EDIT_CUT},
8789
EDIT_SELECTION_COMMANDS: {sectionMarker: Commands.EDIT_SELECT_ALL},
88-
EDIT_FIND_COMMANDS: {sectionMarker: Commands.EDIT_FIND},
89-
EDIT_REPLACE_COMMANDS: {sectionMarker: Commands.EDIT_REPLACE},
9090
EDIT_MODIFY_SELECTION: {sectionMarker: Commands.EDIT_INDENT},
9191
EDIT_COMMENT_SELECTION: {sectionMarker: Commands.EDIT_LINE_COMMENT},
9292
EDIT_CODE_HINTS_COMMANDS: {sectionMarker: Commands.SHOW_CODE_HINTS},
9393
EDIT_TOGGLE_OPTIONS: {sectionMarker: Commands.TOGGLE_CLOSE_BRACKETS},
94-
94+
95+
// DEPRECATED: Old Edit menu sections redirected to existing Edit menu section
96+
EDIT_FIND_COMMANDS: {sectionMarker: Commands.TOGGLE_CLOSE_BRACKETS},
97+
EDIT_REPLACE_COMMANDS: {sectionMarker: Commands.TOGGLE_CLOSE_BRACKETS},
98+
99+
FIND_FIND_COMMANDS: {sectionMarker: Commands.CMD_FIND},
100+
FIND_FIND_IN_COMMANDS: {sectionMarker: Commands.CMD_FIND_IN_FILES},
101+
FIND_REPLACE_COMMANDS: {sectionMarker: Commands.CMD_REPLACE},
102+
95103
VIEW_HIDESHOW_COMMANDS: {sectionMarker: Commands.VIEW_HIDE_SIDEBAR},
96104
VIEW_FONTSIZE_COMMANDS: {sectionMarker: Commands.VIEW_INCREASE_FONT_SIZE},
97105
VIEW_TOGGLE_OPTIONS: {sectionMarker: Commands.TOGGLE_ACTIVE_LINE},
@@ -359,7 +367,7 @@ define(function (require, exports, module) {
359367
*/
360368
Menu.prototype._getRelativeMenuItem = function (relativeID, position) {
361369
var $relativeElement;
362-
370+
363371
if (relativeID) {
364372
if (position === FIRST_IN_SECTION || position === LAST_IN_SECTION) {
365373
if (!relativeID.hasOwnProperty("sectionMarker")) {
@@ -547,7 +555,15 @@ define(function (require, exports, module) {
547555
menuItem,
548556
name,
549557
commandID;
550-
558+
559+
if (relativeID === MenuSection.EDIT_FIND_COMMANDS) {
560+
DeprecationWarning.deprecationWarning("Add " + command + " Command to the Find Menu instead of the Edit Menu.", true);
561+
DeprecationWarning.deprecationWarning("Use MenuSection.FIND_FIND_COMMANDS instead of MenuSection.EDIT_FIND_COMMANDS.", true);
562+
} else if (relativeID === MenuSection.EDIT_REPLACE_COMMANDS) {
563+
DeprecationWarning.deprecationWarning("Add " + command + " Command to the Find Menu instead of the Edit Menu.", true);
564+
DeprecationWarning.deprecationWarning("Use MenuSection.FIND_REPLACE_COMMANDS instead of MenuSection.EDIT_REPLACE_COMMANDS.", true);
565+
}
566+
551567
if (!command) {
552568
console.error("addMenuItem(): missing required parameters: command");
553569
return null;

0 commit comments

Comments
 (0)