@@ -35,6 +35,16 @@ define(function (require, exports, module) {
3535 */
3636 var SYNC_ERROR_CLASS = "live-preview-sync-error" ;
3737
38+ function _simpleHash ( str ) {
39+ let hash = 5381 ;
40+ for ( let i = 0 ; i < str . length ; ) {
41+ // eslint-disable-next-line no-bitwise
42+ hash = ( hash * 33 ) ^ str . charCodeAt ( i ++ ) ;
43+ }
44+ // eslint-disable-next-line no-bitwise
45+ return hash >>> 0 ;
46+ }
47+
3848 /**
3949 * @constructor
4050 * Base class for managing the connection between a live editor and the browser. Provides functions
@@ -64,8 +74,9 @@ define(function (require, exports, module) {
6474 this . _onActiveEditorChange = this . _onActiveEditorChange . bind ( this ) ;
6575 this . _onCursorActivity = this . _onCursorActivity . bind ( this ) ;
6676
67- EditorManager . off ( `activeEditorChange.LiveDocument-${ this . doc . file . fullPath } ` ) ;
68- EditorManager . on ( `activeEditorChange.LiveDocument-${ this . doc . file . fullPath } ` , this . _onActiveEditorChange ) ;
77+ this . fileHashForEvents = _simpleHash ( this . doc . file . fullPath ) ;
78+ EditorManager . off ( `activeEditorChange.LiveDocument-${ this . fileHashForEvents } ` ) ;
79+ EditorManager . on ( `activeEditorChange.LiveDocument-${ this . fileHashForEvents } ` , this . _onActiveEditorChange ) ;
6980
7081 if ( editor ) {
7182 // Attach now
@@ -79,7 +90,7 @@ define(function (require, exports, module) {
7990 * Closes the live document, terminating its connection to the browser.
8091 */
8192 LiveDocument . prototype . close = function ( ) {
82- EditorManager . off ( `activeEditorChange.LiveDocument-${ this . doc . file . fullPath } ` ) ;
93+ EditorManager . off ( `activeEditorChange.LiveDocument-${ this . fileHashForEvents } ` ) ;
8394 this . _clearErrorDisplay ( ) ;
8495 this . _detachFromEditor ( ) ;
8596 } ;
0 commit comments