Skip to content

Commit

Permalink
Changing ODS no longer restarts the screen.
Browse files Browse the repository at this point in the history
fixes #1347
  • Loading branch information
vchelaru committed Feb 6, 2024
1 parent 74321b9 commit fc0cd19
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,18 @@ public async void HandleFileChanged(FilePath fileName)
ShouldRestartOnChange &&
GetIfShouldReactToFileChange(fileName);

var rfses = GlueCommands.Self.FileCommands.GetReferencedFiles(fileName.FullPath);
var rfsesUsingSource = GlueCommands.Self.FileCommands.GetReferencedFilesUsingSourceFile(fileName);

if(shouldReactToFileChange && rfses.Count > 0)
if(shouldReactToFileChange && rfsesUsingSource.Count > 0)
{
// If this file is only used to build other files (like an ODS -> CSV), then do not
// If this file is used to build other files (like an ODS -> CSV), then do not
// react to this change since the built file should result in a reaction:
var areAllBuilt = rfses.All(item => item.IsFileSourceForThis(fileName));
shouldReactToFileChange = false;
}

if (shouldReactToFileChange)
{
var rfses = GlueCommands.Self.FileCommands.GetReferencedFiles(fileName.FullPath);
var firstRfs = rfses.FirstOrDefault();
var isGlobalContent = rfses.Any(item => item.GetContainer() == null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,48 @@ public List<ReferencedFileSave> GetReferencedFiles(FilePath filePath)
return files;
}

public List<ReferencedFileSave> GetReferencedFilesUsingSourceFile(FilePath filePath)
{
List<ReferencedFileSave> files = new List<ReferencedFileSave>();

if (GlueProject != null)
{
foreach (ScreenSave screenSave in GlueProject.Screens.ToArray())
{
foreach (ReferencedFileSave rfs in screenSave.ReferencedFiles.ToArray())
{
if (!string.IsNullOrEmpty(rfs.SourceFile) && GlueCommands.Self.GetAbsoluteFilePath(rfs.SourceFile) == filePath)
{
files.Add(rfs);
}
}
}

foreach (EntitySave entitySave in GlueProject.Entities.ToArray())
{
foreach (ReferencedFileSave rfs in entitySave.ReferencedFiles.ToArray())
{
if (!string.IsNullOrEmpty(rfs.SourceFile) && GlueCommands.Self.GetAbsoluteFilePath(rfs.SourceFile) == filePath)
{
files.Add(rfs);
}
}
}

foreach (ReferencedFileSave rfs in GlueProject.GlobalFiles.ToArray())
{
if (!string.IsNullOrEmpty(rfs.SourceFile) && GlueCommands.Self.GetAbsoluteFilePath(rfs.SourceFile) == filePath)
{
files.Add(rfs);
}
}
}

return files;
}



public GeneralResponse GetLastParseResponse(FilePath file)
{
// only return failure if there is an entry in the FileReferenceManager, otherwise return success:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public interface IFileCommands
FilePath GetFilePath(ReferencedFileSave rfs);
ReferencedFileSave GetReferencedFile(FilePath filePath);
List<ReferencedFileSave> GetReferencedFiles(FilePath filePath);
List<ReferencedFileSave> GetReferencedFilesUsingSourceFile(FilePath filePath);


FilePath GetCustomCodeFilePath(GlueElement glueElement);

Expand Down

0 comments on commit fc0cd19

Please sign in to comment.