@@ -592,7 +592,6 @@ define(function (require, exports, module) {
592592 }
593593 ignoreChange = false ;
594594 } ) ;
595-
596595 ParameterHintManager . installListeners ( editor ) ;
597596 } else {
598597 session = null ;
@@ -622,6 +621,18 @@ define(function (require, exports, module) {
622621 * @param {Editor } previous - the previous editor context
623622 */
624623 function handleActiveEditorChange ( event , current , previous ) {
624+ // Uninstall "languageChanged" event listeners on the previous editor's document
625+ if ( previous && previous !== current ) {
626+ $ ( previous . document )
627+ . off ( HintUtils . eventName ( "languageChanged" ) ) ;
628+ }
629+ if ( current . document !== DocumentManager . getCurrentDocument ( ) ) {
630+ $ ( current . document )
631+ . on ( HintUtils . eventName ( "languageChanged" ) , function ( ) {
632+ uninstallEditorListeners ( current ) ;
633+ installEditorListeners ( current ) ;
634+ } ) ;
635+ }
625636 uninstallEditorListeners ( previous ) ;
626637 installEditorListeners ( current , previous ) ;
627638 }
@@ -792,7 +803,8 @@ define(function (require, exports, module) {
792803 $ ( DocumentManager )
793804 . on ( "currentDocumentLanguageChanged" , function ( e ) {
794805 var activeEditor = EditorManager . getActiveEditor ( ) ;
795- handleActiveEditorChange ( e , activeEditor , activeEditor ) ;
806+ uninstallEditorListeners ( activeEditor ) ;
807+ installEditorListeners ( activeEditor ) ;
796808 } ) ;
797809
798810 $ ( ProjectManager ) . on ( "beforeProjectClose" , function ( ) {
0 commit comments