diff --git a/src/OneWare.Essentials/ViewModels/ExtendedDocument.cs b/src/OneWare.Essentials/ViewModels/ExtendedDocument.cs index 224019ef..74afd61e 100644 --- a/src/OneWare.Essentials/ViewModels/ExtendedDocument.cs +++ b/src/OneWare.Essentials/ViewModels/ExtendedDocument.cs @@ -125,14 +125,18 @@ public virtual Task SaveAsync() public virtual void InitializeContent() { var oldCurrentFile = CurrentFile; - if (CurrentFile?.FullPath != FullPath) + + CurrentFile = _projectExplorerService.SearchFullPath(FullPath) as IFile ?? + _projectExplorerService.GetTemporaryFile(FullPath); + Title = CurrentFile is ExternalFile ? $"[{CurrentFile.Name}]" : CurrentFile.Name; + + if (CurrentFile != oldCurrentFile && oldCurrentFile != null) { - CurrentFile = _projectExplorerService.SearchFullPath(FullPath) as IFile ?? - _projectExplorerService.GetTemporaryFile(FullPath); - Title = CurrentFile is ExternalFile ? $"[{CurrentFile.Name}]" : CurrentFile.Name; + _dockService.OpenFiles.Remove(oldCurrentFile); } - + _dockService.OpenFiles.TryAdd(CurrentFile, this); + UpdateCurrentFile(oldCurrentFile); } diff --git a/src/OneWare.OssCadSuiteIntegration/Simulators/IcarusVerilogSimulator.cs b/src/OneWare.OssCadSuiteIntegration/Simulators/IcarusVerilogSimulator.cs index 89127779..98aef8a8 100644 --- a/src/OneWare.OssCadSuiteIntegration/Simulators/IcarusVerilogSimulator.cs +++ b/src/OneWare.OssCadSuiteIntegration/Simulators/IcarusVerilogSimulator.cs @@ -75,14 +75,11 @@ public async Task SimulateAsync(IFile file) { var vcdFileRelativePath = match.Groups[1].Value; var vcdFileFullPath = Path.Combine(projectFile.Root!.FullPath, vcdFileRelativePath); - - await Task.Delay(50); - + var vcdFile = projectFile.Root.SearchRelativePath(vcdFileRelativePath.ToPlatformPath()) as IFile ?? _projectExplorerService.GetTemporaryFile(vcdFileFullPath); var doc = await _dockService.OpenFileAsync(vcdFile); - if (doc is IStreamableDocument vcd) vcd.PrepareLiveStream(); } return true; diff --git a/src/OneWare.ProjectExplorer/Services/ProjectWatchInstance.cs b/src/OneWare.ProjectExplorer/Services/ProjectWatchInstance.cs index 997e3574..3733ab82 100644 --- a/src/OneWare.ProjectExplorer/Services/ProjectWatchInstance.cs +++ b/src/OneWare.ProjectExplorer/Services/ProjectWatchInstance.cs @@ -153,6 +153,9 @@ private async Task ProcessAsync(string path, IReadOnlyCollection x.ChangeType is WatcherChangeTypes.Created): _root.OnExternalEntryAdded(path, attributes); + var openTab = _dockService.OpenFiles.FirstOrDefault(x => x.Key.FullPath.EqualPaths(path)); + if (openTab.Key is not null) + openTab.Value.InitializeContent(); return; case WatcherChangeTypes.Changed: if (_root is ISavable savable && _root.ProjectPath.EqualPaths(path))