diff --git a/src/HexManiac.Core/Models/Code/ScriptParser.cs b/src/HexManiac.Core/Models/Code/ScriptParser.cs index 025fa1ce..2338d692 100644 --- a/src/HexManiac.Core/Models/Code/ScriptParser.cs +++ b/src/HexManiac.Core/Models/Code/ScriptParser.cs @@ -879,7 +879,7 @@ namespace HavenSoft.HexManiac.Core.Models.Code { // (1) the run has no name // (2) the run has only one source (the script) if (run is NoInfoRun || run.PointerSources == null) return -1; - if (run is IScriptStartRun) return -1; // this script has a length, but don't track it (prevent recursion loop) + if (run is IScriptStartRun) return 1; // this script has a length, but don't calculate it (prevent recursion loop) if (run.PointerSources.Count == 1 && string.IsNullOrEmpty(model.GetAnchorFromAddress(-1, destination))) { return run.Length; } diff --git a/src/HexManiac.Tests/CodeToolTests.cs b/src/HexManiac.Tests/CodeToolTests.cs index faf8fa0d..a8bb9d59 100644 --- a/src/HexManiac.Tests/CodeToolTests.cs +++ b/src/HexManiac.Tests/CodeToolTests.cs @@ -873,5 +873,15 @@ label2:;goto <000050>;end"; Assert.Equal(8, run.Start); Assert.IsType(run); } + + [Fact] + public void ScriptGotoBeforeScriptStarts_Reload_IncludesSubScript() { + EventScript = "end"; + ViewPort.Goto.Execute(0x10); + + EventScript = "if.yes.goto ;end;section1:;if.yes.goto <000000>;end"; + + Assert.Equal(2, Tool.Contents.Count); + } } }