diff --git a/src/HexManiac.Core/ViewModels/ViewPort.cs b/src/HexManiac.Core/ViewModels/ViewPort.cs index fc3eca72..453e6331 100644 --- a/src/HexManiac.Core/ViewModels/ViewPort.cs +++ b/src/HexManiac.Core/ViewModels/ViewPort.cs @@ -2508,7 +2508,8 @@ namespace HavenSoft.HexManiac.Core.ViewModels { if (completeEditOperation.Result) { // if the data we just changed was in a table, notify children of that table about the change - if (Model.GetNextRun(dataIndex) is ITableRun tableRun) { + var previousRun = Model.GetNextRun(dataIndex); + if (previousRun is ITableRun tableRun) { var offsets = tableRun.ConvertByteOffsetToArrayOffset(dataIndex); var errorInfo = tableRun.NotifyChildren(Model, history.CurrentChange, offsets.ElementIndex, offsets.SegmentIndex); HandleErrorInfo(errorInfo); @@ -2527,11 +2528,11 @@ namespace HavenSoft.HexManiac.Core.ViewModels { var run = Model.GetNextRun(completeEditOperation.NewDataIndex); if (run.Start > completeEditOperation.NewDataIndex) run = new NoInfoRun(Model.Count); if (completeEditOperation.DataMoved) UpdateToolsFromSelection(run.Start); - if (run is ITableRun) { + if (run is ITableRun || previousRun is ITableRun) { Tools.Schedule(Tools.TableTool.DataForCurrentRunChanged); } - if (run is ITableRun || run is IStreamRun) Tools.Schedule(Tools.StringTool.DataForCurrentRunChanged); - if (run is ISpriteRun || run is IPaletteRun) { + if (run is ITableRun || run is IStreamRun || previousRun is ITableRun || previousRun is IStreamRun) Tools.Schedule(Tools.StringTool.DataForCurrentRunChanged); + if (run is ISpriteRun || run is IPaletteRun || previousRun is ISpriteRun || previousRun is IPaletteRun) { tools.Schedule(tools.SpriteTool.DataForCurrentRunChanged); tools.Schedule(tools.TableTool.DataForCurrentRunChanged); } diff --git a/src/HexManiac.Tests/Before_Baseclass/StringModelTests.cs b/src/HexManiac.Tests/Before_Baseclass/StringModelTests.cs index dce41024..bf95d0ab 100644 --- a/src/HexManiac.Tests/Before_Baseclass/StringModelTests.cs +++ b/src/HexManiac.Tests/Before_Baseclass/StringModelTests.cs @@ -709,6 +709,18 @@ namespace HavenSoft.HexManiac.Tests { Assert.True("a.e".MatchesPartialWithReordering("éá")); } + [Fact] + public void AsciiText_LastEdit_Notify() { + SetFullModel(0xFF); + ViewPort.Edit("^test`asc`7 123456"); + + var view = new StubView(ViewPort.Tools.StringTool); + ViewPort.Edit("7"); + + Assert.Equal("1234567", ViewPort.Tools.StringTool.Content); + Assert.Contains(nameof(ViewPort.Tools.StringTool.Content), view.PropertyNotifications); + } + private void HackTextConverter(string game) { var converter = new PCSConverter(game); var property = Model.GetType().GetProperty(nameof(Model.TextConverter)); diff --git a/src/HexManiac.Tests/TableTests.cs b/src/HexManiac.Tests/TableTests.cs index cc491f08..830f262a 100644 --- a/src/HexManiac.Tests/TableTests.cs +++ b/src/HexManiac.Tests/TableTests.cs @@ -1140,6 +1140,17 @@ namespace HavenSoft.HexManiac.Tests { Assert.Equal(16, seg.GetOptions(Model).Count()); } + [Fact] + public void Table_UpdateLastElement_TableToolUpdates() { + ViewPort.Edit("^table[a: b:]4 "); + + ViewPort.Goto.Execute(0xF); + ViewPort.Edit("10 "); + + var field = (FieldArrayElementViewModel)ViewPort.Tools.TableTool.Children.Last(); + Assert.Equal("10", field.Content); + } + private void ArrangeTrainerPokemonTeamData(byte structType, byte pokemonCount, int trainerCount) { CreateTextTable(HardcodeTablesModel.PokemonNameTable, 0x180, "ABCDEFGHIJKLMNOP".Select(c => c.ToString()).ToArray()); CreateTextTable(HardcodeTablesModel.MoveNamesTable, 0x1B0, "qrstuvwxyz".Select(c => c.ToString()).ToArray());