Наша сборка Qt VS Tools
giy
2022-09-02 ca47896204482bf4a6979e3838bf7f09f61cebeb
QtVsTools.Package/Editors/Editor.QtDesigner.cs
@@ -31,12 +31,15 @@
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Shell.Interop;
using QtVsTools.QtMsBuild;
using QtVsTools.VisualStudio;
using Microsoft.VisualStudio.Shell;
using Task = System.Threading.Tasks.Task;
namespace QtVsTools.Editors
{
    using QtMsBuild;
    using VisualStudio;
    [Guid(GuidString)]
    public class QtDesigner : Editor
    {
@@ -58,27 +61,31 @@
        protected override void OnStart(Process process)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            base.OnStart(process);
            var document = VsShell.GetDocument(Context, ItemId);
            if (document == null)
                return;
            var project = document.ProjectItem?.ContainingProject;
            if (project == null || !QtProjectTracker.IsTracked(project))
            if (project == null || !QtProjectTracker.IsTracked(project.FullName))
                return;
            string projectPath = project.FullName;
            string filePath = document.FullName;
            string[] itemId = new[] { document.ProjectItem?.Name };
            var lastWriteTime = File.GetLastWriteTime(filePath);
            Task.Run(() =>
            _ = Task.Run(async () =>
            {
                while (!process.WaitForExit(1000)) {
                    var latestWriteTime = File.GetLastWriteTime(filePath);
                    if (lastWriteTime != latestWriteTime) {
                        lastWriteTime = latestWriteTime;
                        QtProjectIntellisense.Refresh(project, selectedFiles: itemId);
                        await QtProjectIntellisense.RefreshAsync(project, projectPath);
                    }
                }
                if (lastWriteTime != File.GetLastWriteTime(filePath)) {
                    QtProjectIntellisense.Refresh(project, selectedFiles: itemId);
                    await QtProjectIntellisense.RefreshAsync(project, projectPath);
                }
            });
        }