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

Commit f24586f

Browse files
committed
Merge pull request #10154 from adobe/dangoor/10115-break-cycle
Fix error on startup due to module cycle
2 parents 9b4efb8 + bec5264 commit f24586f

File tree

2 files changed

+36
-31
lines changed

2 files changed

+36
-31
lines changed

src/command/DefaultMenus.js

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ define(function (require, exports, module) {
3333

3434
var AppInit = require("utils/AppInit"),
3535
Commands = require("command/Commands"),
36-
EditorManager = require("editor/EditorManager"),
3736
Menus = require("command/Menus"),
3837
Strings = require("strings");
3938

@@ -271,38 +270,40 @@ define(function (require, exports, module) {
271270
* an existing selection
272271
*/
273272
$("#editor-holder").on("contextmenu", function (e) {
274-
if ($(e.target).parents(".CodeMirror-gutter").length !== 0) {
275-
return;
276-
}
277-
278-
// Note: on mousedown before this event, CodeMirror automatically checks mouse pos, and
279-
// if not clicking on a selection moves the cursor to click location. When triggered
280-
// from keyboard, no pre-processing occurs and the cursor/selection is left as is.
281-
282-
var editor = EditorManager.getFocusedEditor(),
283-
inlineWidget = EditorManager.getFocusedInlineWidget();
284-
285-
if (editor) {
286-
// If there's just an insertion point select the word token at the cursor pos so
287-
// it's more clear what the context menu applies to.
288-
if (!editor.hasSelection()) {
289-
editor.selectWordAt(editor.getCursorPos());
290-
291-
// Prevent menu from overlapping text by moving it down a little
292-
// Temporarily backout this change for now to help mitigate issue #1111,
293-
// which only happens if mouse is not over context menu. Better fix
294-
// requires change to bootstrap, which is too risky for now.
295-
//e.pageY += 6;
273+
require(["editor/EditorManager"], function (EditorManager) {
274+
if ($(e.target).parents(".CodeMirror-gutter").length !== 0) {
275+
return;
296276
}
297-
298-
// Inline text editors have a different context menu (safe to assume it's not some other
299-
// type of inline widget since we already know an Editor has focus)
300-
if (inlineWidget) {
301-
inline_editor_cmenu.open(e);
302-
} else {
303-
editor_cmenu.open(e);
277+
278+
// Note: on mousedown before this event, CodeMirror automatically checks mouse pos, and
279+
// if not clicking on a selection moves the cursor to click location. When triggered
280+
// from keyboard, no pre-processing occurs and the cursor/selection is left as is.
281+
282+
var editor = EditorManager.getFocusedEditor(),
283+
inlineWidget = EditorManager.getFocusedInlineWidget();
284+
285+
if (editor) {
286+
// If there's just an insertion point select the word token at the cursor pos so
287+
// it's more clear what the context menu applies to.
288+
if (!editor.hasSelection()) {
289+
editor.selectWordAt(editor.getCursorPos());
290+
291+
// Prevent menu from overlapping text by moving it down a little
292+
// Temporarily backout this change for now to help mitigate issue #1111,
293+
// which only happens if mouse is not over context menu. Better fix
294+
// requires change to bootstrap, which is too risky for now.
295+
//e.pageY += 6;
296+
}
297+
298+
// Inline text editors have a different context menu (safe to assume it's not some other
299+
// type of inline widget since we already know an Editor has focus)
300+
if (inlineWidget) {
301+
inline_editor_cmenu.open(e);
302+
} else {
303+
editor_cmenu.open(e);
304+
}
304305
}
305-
}
306+
});
306307
});
307308

308309
/**

src/project/ProjectManager.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ define(function (require, exports, module) {
7474
ProjectModel = require("project/ProjectModel"),
7575
FileTreeView = require("project/FileTreeView"),
7676
ViewUtils = require("utils/ViewUtils");
77+
78+
// Needed to ensure that menus are set up when we need them.
79+
// See #10115
80+
require("command/DefaultMenus");
7781

7882
/**
7983
* @private

0 commit comments

Comments
 (0)