@@ -33,13 +33,13 @@ sys.inherits(cloud9WatcherPlugin, Plugin);
3333( function ( ) {
3434 this . unwatchFile = function ( filename ) {
3535 // console.log("No longer watching file " + filename);
36- delete this . filenames [ filename ] ;
37- fs . unwatchFile ( filename ) ;
36+ if ( -- this . filenames [ filename ] == 0 ) {
37+ delete this . filenames [ filename ] ;
38+ fs . unwatchFile ( filename ) ;
39+ }
3840 return true ;
3941 } ;
4042
41- // TODO: this does not look correct. There could be more than one client be
42- // attached. There needs to be a per client list with ref counting
4343 this . disconnect = function ( ) {
4444 for ( var filename in this . filenames )
4545 this . unwatchFile ( filename ) ;
@@ -58,7 +58,7 @@ sys.inherits(cloud9WatcherPlugin, Plugin);
5858 switch ( type ) {
5959 case "watchFile" :
6060 if ( this . filenames [ path ] )
61- ; // console.log("Already watching file " + path);
61+ ++ this . filenames [ path ] ; // console.log("Already watching file " + path);
6262 else {
6363 // console.log("Watching file " + path);
6464 that = this ;
@@ -100,7 +100,7 @@ sys.inherits(cloud9WatcherPlugin, Plugin);
100100 } ) ) ;
101101 console . log ( "Sent " + subtype + " notification for file " + path ) ;
102102 } ) ;
103- this . filenames [ path ] = path ;
103+ this . filenames [ path ] = 0 ;
104104 }
105105 return true ;
106106 case "unwatchFile" :
0 commit comments