better file syncing (poorly)

This commit is contained in:
Matt Parker
2025-10-18 12:47:00 +10:00
parent 639945007b
commit 4d67503e13
4 changed files with 27 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
using SharpIDE.Application.Features.Analysis;
using SharpIDE.Application.Features.Evaluation;
using SharpIDE.Application.Features.Events;
using SharpIDE.Application.Features.FilePersistence;
using SharpIDE.Application.Features.SolutionDiscovery;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
@@ -38,6 +39,16 @@ public class IdeFileSavedToDiskHandler
private async Task HandleWorkspaceFileChanged(SharpIdeFile file)
{
// TODO: Don't reload from disk if we raised the change event ourselves (e.g. save from IDE). Cleanup this whole disaster
var wasOpenAndUpdated = await IdeOpenTabsFileManager.Instance.ReloadFileFromDiskIfOpenInEditor(file);
if (file.IsRoslynWorkspaceFile)
{
var fileText = wasOpenAndUpdated ?
await IdeOpenTabsFileManager.Instance.GetFileTextAsync(file) :
await File.ReadAllTextAsync(file.Path);
await RoslynAnalysis.UpdateDocument(file, fileText);
GlobalEvents.Instance.SolutionAltered.InvokeParallelFireAndForget();
}
await RoslynAnalysis.UpdateSolutionDiagnostics();
}
}