handle ignoring events better

This commit is contained in:
Matt Parker
2025-10-10 18:09:15 +10:00
parent f65ad7f18c
commit 6474150b07
3 changed files with 16 additions and 10 deletions

View File

@@ -15,7 +15,16 @@ public class IdeFileChangeHandler
{
var sharpIdeFile = SolutionModel.AllFiles.SingleOrDefault(f => f.Path == filePath);
if (sharpIdeFile is null) return;
if (sharpIdeFile.SuppressDiskChangeEvents.Value is true) return;
if (sharpIdeFile.SuppressDiskChangeEvents is true) return;
if (sharpIdeFile.LastIdeWriteTime is not null)
{
var now = DateTimeOffset.Now;
if (now - sharpIdeFile.LastIdeWriteTime.Value < TimeSpan.FromMilliseconds(300))
{
Console.WriteLine($"IdeFileChangeHandler: Ignored - {filePath}");
return;
}
}
Console.WriteLine($"IdeFileChangeHandler: Changed - {filePath}");
await sharpIdeFile.FileContentsChangedExternallyFromDisk.InvokeParallelAsync();
}