mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-05-19 11:53:10 -05:00
fix script formatting bug
formatting a script should not remove inner anchors
This commit is contained in:
parent
2a5f36ee6f
commit
a0254ef8ea
|
|
@ -2367,7 +2367,11 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
|
|||
Goto.Execute(addressText);
|
||||
Debug.Assert(scroll.DataIndex == address - address % 16);
|
||||
var length = tools.CodeTool.ScriptParser.GetScriptSegmentLength(Model, address);
|
||||
Model.ClearFormat(CurrentChange, address, length - 1);
|
||||
|
||||
// clear format in a way that won't remove inner-anchors, since some scripts point into other scripts
|
||||
for (var run = Model.GetNextRun(address); run.Start < address + length; run = Model.GetNextRun(run.Start + run.Length)) {
|
||||
Model.ClearFormat(CurrentChange, address, 1);
|
||||
}
|
||||
|
||||
using (ModelCacheScope.CreateScope(Model)) {
|
||||
tools.CodeTool.ScriptParser.FormatScript<XSERun>(CurrentChange, Model, address);
|
||||
|
|
|
|||
|
|
@ -141,5 +141,30 @@ namespace HavenSoft.HexManiac.Tests {
|
|||
|
||||
Assert.Equal(4, Tool.Contents.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ScriptWithInnerAnchor_AddScriptFormat_AnchorKept() {
|
||||
Tool.Mode = CodeMode.Script;
|
||||
EventScript = "lock;faceplayer;end";
|
||||
ViewPort.Edit("@010 <001>");
|
||||
|
||||
ViewPort.Goto.Execute(0);
|
||||
ViewPort.Edit("^`xse`");
|
||||
|
||||
Assert.IsType<PointerRun>(Model.GetNextRun(0x10));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ScriptWithInnerAnchor_AddPointerAtThatLocation_AnchorRemoved() {
|
||||
Tool.Mode = CodeMode.Script;
|
||||
EventScript = "lock;if1 = <100>;end";
|
||||
ViewPort.Edit("@010 <005>"); // points into the pointer
|
||||
|
||||
ViewPort.Goto.Execute(0);
|
||||
ViewPort.Edit("^`xse`");
|
||||
|
||||
Assert.IsType<PointerRun>(Model.GetNextRun(5));
|
||||
Model.ResolveConflicts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user