瀏覽代碼

fixed multiple ignoreNext

Nicolas Cannasse 5 年之前
父節點
當前提交
8145490b71
共有 1 個文件被更改,包括 5 次插入5 次删除
  1. 5 5
      hide/tools/FileWatcher.hx

+ 5 - 5
hide/tools/FileWatcher.hx

@@ -5,7 +5,7 @@ private typedef FileEvent = {path:String,fun:Void->Void,checkDel:Bool,element:js
 class FileWatcher {
 class FileWatcher {
 
 
 	var ide : hide.Ide;
 	var ide : hide.Ide;
-	var watches : Map<String,{ events : Array<FileEvent>, w : js.node.fs.FSWatcher, ignoreNext : Bool, wasChanged : Bool, changed : Bool, isDir : Bool }> = new Map();
+	var watches : Map<String,{ events : Array<FileEvent>, w : js.node.fs.FSWatcher, ignoreNext : Int, wasChanged : Bool, changed : Bool, isDir : Bool }> = new Map();
 	var timer : haxe.Timer;
 	var timer : haxe.Timer;
 
 
 	public function new() {
 	public function new() {
@@ -14,7 +14,7 @@ class FileWatcher {
 
 
 	public function ignoreNextChange( path : String ) {
 	public function ignoreNextChange( path : String ) {
 		var w = getWatches(path);
 		var w = getWatches(path);
-		w.ignoreNext = true;
+		w.ignoreNext++;
 	}
 	}
 
 
 	public function dispose() {
 	public function dispose() {
@@ -88,7 +88,7 @@ class FileWatcher {
 				w : null,
 				w : null,
 				changed : false,
 				changed : false,
 				isDir : try sys.FileSystem.isDirectory(fullPath) catch( e : Dynamic ) false,
 				isDir : try sys.FileSystem.isDirectory(fullPath) catch( e : Dynamic ) false,
-				ignoreNext : false,
+				ignoreNext : 0,
 				wasChanged : false,
 				wasChanged : false,
 			};
 			};
 			w.w = try js.node.Fs.watch(fullPath, function(k:String, file:String) {
 			w.w = try js.node.Fs.watch(fullPath, function(k:String, file:String) {
@@ -99,8 +99,8 @@ class FileWatcher {
 				haxe.Timer.delay(function() {
 				haxe.Timer.delay(function() {
 					if( !w.changed ) return;
 					if( !w.changed ) return;
 					w.changed = false;
 					w.changed = false;
-					if( w.ignoreNext ) {
-						w.ignoreNext = false;
+					if( w.ignoreNext > 0 ) {
+						w.ignoreNext--;
 						return;
 						return;
 					}
 					}
 					for( e in w.events.copy() )
 					for( e in w.events.copy() )