@@ -340,7 +340,7 @@ define(function (require, exports, module) {
340340 params [ i ] = args . join ( " " ) ;
341341 }
342342
343- // put it back together.
343+ // put it back together.
344344 expression = expression . substring ( 0 , paramStart ) + params . join ( ", " ) + expression . substring ( paramEnd ) ;
345345 }
346346 return expression ;
@@ -516,6 +516,42 @@ define(function (require, exports, module) {
516516 return null ;
517517 }
518518
519+ function getHoveredEditor ( event ) {
520+ // Figure out which editor we are over
521+ var fullEditor = EditorManager . getCurrentFullEditor ( ) ;
522+
523+ if ( ! fullEditor ) {
524+ return ;
525+ }
526+
527+ // Check for inline Editor instances first
528+ var inlines = fullEditor . getInlineWidgets ( ) ,
529+ i ,
530+ editor ;
531+
532+ for ( i = 0 ; i < inlines . length ; i ++ ) {
533+ var $inlineEditorRoot = inlines [ i ] . editor && $ ( inlines [ i ] . editor . getRootElement ( ) ) , // see MultiRangeInlineEditor
534+ $otherDiv = inlines [ i ] . $htmlContent ;
535+
536+ if ( $inlineEditorRoot && divContainsMouse ( $inlineEditorRoot , event ) ) {
537+ editor = inlines [ i ] . editor ;
538+ break ;
539+ } else if ( $otherDiv && divContainsMouse ( $otherDiv , event ) ) {
540+ // Mouse inside unsupported inline editor like Quick Docs or Color Editor
541+ return ;
542+ }
543+ }
544+
545+ // Check main editor
546+ if ( ! editor ) {
547+ if ( divContainsMouse ( $ ( fullEditor . getRootElement ( ) ) , event ) ) {
548+ editor = fullEditor ;
549+ }
550+ }
551+
552+ return editor ;
553+ }
554+
519555 /**
520556 * Changes the current hidden popoverState to visible, showing it in the UI and highlighting
521557 * its matching text in the editor.
@@ -563,39 +599,7 @@ define(function (require, exports, module) {
563599 return ;
564600 }
565601
566- // Figure out which editor we are over
567- var fullEditor = EditorManager . getCurrentFullEditor ( ) ;
568-
569- if ( ! fullEditor ) {
570- hidePreview ( ) ;
571- return ;
572- }
573-
574- // Check for inline Editor instances first
575- var inlines = fullEditor . getInlineWidgets ( ) ,
576- i ,
577- editor ;
578-
579- for ( i = 0 ; i < inlines . length ; i ++ ) {
580- var $inlineEditorRoot = inlines [ i ] . editor && $ ( inlines [ i ] . editor . getRootElement ( ) ) , // see MultiRangeInlineEditor
581- $otherDiv = inlines [ i ] . $htmlContent ;
582-
583- if ( $inlineEditorRoot && divContainsMouse ( $inlineEditorRoot , event ) ) {
584- editor = inlines [ i ] . editor ;
585- break ;
586- } else if ( $otherDiv && divContainsMouse ( $otherDiv , event ) ) {
587- // Mouse inside unsupported inline editor like Quick Docs or Color Editor
588- hidePreview ( ) ;
589- return ;
590- }
591- }
592-
593- // Check main editor
594- if ( ! editor ) {
595- if ( divContainsMouse ( $ ( fullEditor . getRootElement ( ) ) , event ) ) {
596- editor = fullEditor ;
597- }
598- }
602+ var editor = getHoveredEditor ( event ) ;
599603
600604 if ( editor && editor . _codeMirror ) {
601605 // Find char mouse is over
@@ -622,7 +626,7 @@ define(function (require, exports, module) {
622626 // That one's still relevant - nothing more to do
623627 return ;
624628 } else {
625- // That one doesn't cover this pos - hide it and start anew
629+ // That one doesn't cover this pos - hide it and start a new
626630 showImmediately = popoverState . visible ;
627631 hidePreview ( ) ;
628632 }
@@ -640,7 +644,7 @@ define(function (require, exports, module) {
640644 } , showImmediately ? 0 : HOVER_DELAY ) ;
641645
642646 } else {
643- // Mouse not over any Editor - immediately hide popover
647+ // Mouse not over any supported Editor - immediately hide popover
644648 hidePreview ( ) ;
645649 }
646650 }
0 commit comments