From afea2108678972c9ca86d8e62ddd0430af1a0128 Mon Sep 17 00:00:00 2001 From: Benjamin Popp Date: Tue, 13 Jul 2021 22:51:54 -0500 Subject: [PATCH] UI is trying to update selectedIndex during reset. Don't allow that. --- .../ViewModels/Tools/IndexComboBoxViewModel.cs | 2 +- src/HexManiac.Tests/TableTests.cs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/HexManiac.Core/ViewModels/Tools/IndexComboBoxViewModel.cs b/src/HexManiac.Core/ViewModels/Tools/IndexComboBoxViewModel.cs index b1d9790d..b60586b2 100644 --- a/src/HexManiac.Core/ViewModels/Tools/IndexComboBoxViewModel.cs +++ b/src/HexManiac.Core/ViewModels/Tools/IndexComboBoxViewModel.cs @@ -23,7 +23,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Tools { get => selectedVisibleIndex; set { if (value == -1) return; - if (selectedVisibleIndex != value) { + if (selectedVisibleIndex != value && !resetting) { selectedIndex = allOptions.IndexOf(Options[value]); ResetFilter(); UpdateSelection?.Invoke(this, EventArgs.Empty); diff --git a/src/HexManiac.Tests/TableTests.cs b/src/HexManiac.Tests/TableTests.cs index 0d6955dc..d926f10e 100644 --- a/src/HexManiac.Tests/TableTests.cs +++ b/src/HexManiac.Tests/TableTests.cs @@ -1,6 +1,7 @@ using HavenSoft.HexManiac.Core; using HavenSoft.HexManiac.Core.Models; using HavenSoft.HexManiac.Core.Models.Runs; +using HavenSoft.HexManiac.Core.ViewModels; using HavenSoft.HexManiac.Core.ViewModels.DataFormats; using HavenSoft.HexManiac.Core.ViewModels.Tools; using HavenSoft.HexManiac.Core.ViewModels.Visitors; @@ -799,4 +800,11 @@ namespace HavenSoft.HexManiac.Tests { ViewPort.Goto.Execute("00"); } } + + public static class TableToolTestExtensions { + public static FieldArrayElementViewModel GetField(this TableTool table, string name) { + var child = table.Children.Single(vm => vm is FieldArrayElementViewModel fvm && fvm.Name == name); + return (FieldArrayElementViewModel)child; + } + } }