@@ -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 /**
0 commit comments