mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-10-02 05:06:35 -05:00
Make it possible to remove matched words
This commit is contained in:
@@ -748,6 +748,10 @@ namespace HavenSoft.HexManiac.Core.Models {
|
||||
if (run.Start >= start + length) return;
|
||||
if (run is PointerRun) ClearPointerFormat(null, changeToken, run.Start);
|
||||
if (run is ArrayRun arrayRun) ModifyAnchorsFromPointerArray(changeToken, arrayRun, ClearPointerFormat);
|
||||
if (run is WordRun wordRun) {
|
||||
changeToken.RemoveMatchedWord(wordRun.Start, wordRun.SourceArrayName);
|
||||
matchedWords[wordRun.SourceArrayName].Remove(wordRun.Start);
|
||||
}
|
||||
|
||||
ClearAnchorFormat(changeToken, originalStart, run);
|
||||
|
||||
|
||||
@@ -1024,6 +1024,30 @@ namespace HavenSoft.HexManiac.Tests {
|
||||
Assert.Equal(5, length);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanRemoveLooseWordRuns() {
|
||||
StandardSetup(out var data, out var model, out var viewPort);
|
||||
viewPort.Edit("^table[a:: b::]4 "); // 0x20 bytes
|
||||
|
||||
// add the format
|
||||
viewPort.SelectionStart = new Point(0, 5);
|
||||
viewPort.Edit("::table "); // should create a new 4-byte run that stays in sync with the table
|
||||
|
||||
// remove the format
|
||||
var items = viewPort.GetContextMenuItems(new Point(0, 5));
|
||||
var contextItem = items.Single(item => item.Text == "Clear Format");
|
||||
contextItem.Command.Execute();
|
||||
|
||||
// extend the table
|
||||
viewPort.SelectionStart = new Point(0, 2);
|
||||
viewPort.Edit("+");
|
||||
|
||||
// verify that the table was extended, but the value at 0x50 was NOT (no longer tied together)
|
||||
Assert.Equal(5, ((ArrayRun)model.GetNextRun(0)).ElementCount);
|
||||
var length = model.ReadValue(0x50);
|
||||
Assert.Equal(4, length);
|
||||
}
|
||||
|
||||
private static void StandardSetup(out byte[] data, out PokemonModel model, out ViewPort viewPort) {
|
||||
data = new byte[0x200];
|
||||
model = new PokemonModel(data);
|
||||
|
||||
Reference in New Issue
Block a user