From 32b26068da2810fb7d8e41296ea9b66aa5bcdd79 Mon Sep 17 00:00:00 2001 From: Benjamin Popp Date: Sat, 1 Dec 2018 23:23:56 -0600 Subject: [PATCH] provide a default value for recentFindResults to avoid null checks. --- Gen3Hex/ViewModel/EditorViewModel.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gen3Hex/ViewModel/EditorViewModel.cs b/Gen3Hex/ViewModel/EditorViewModel.cs index a4fca739..cc9a695d 100644 --- a/Gen3Hex/ViewModel/EditorViewModel.cs +++ b/Gen3Hex/ViewModel/EditorViewModel.cs @@ -42,7 +42,7 @@ namespace HavenSoft.Gen3Hex.ViewModel { private readonly Dictionary, EventHandler> forwardExecuteChangeNotifications; - private (IViewPort tab, int)[] recentFindResults; + private (IViewPort tab, int)[] recentFindResults = new (IViewPort, int)[0]; private int currentFindResultIndex; public ICommand New => newCommand; @@ -208,7 +208,7 @@ namespace HavenSoft.Gen3Hex.ViewModel { find.CanExecute = CanAlwaysExecute; find.Execute = arg => FindExecuted((string)arg); - findPrevious.CanExecute = arg => recentFindResults?.Any(pair => pair.tab == SelectedTab) ?? false; + findPrevious.CanExecute = arg => recentFindResults.Any(pair => pair.tab == SelectedTab); findPrevious.Execute = arg => { int attemptCount = 0; while (attemptCount < recentFindResults.Length) { @@ -222,7 +222,7 @@ namespace HavenSoft.Gen3Hex.ViewModel { } }; - findNext.CanExecute = arg => recentFindResults?.Any(pair => pair.tab == SelectedTab) ?? false; + findNext.CanExecute = arg => recentFindResults.Any(pair => pair.tab == SelectedTab); findNext.Execute = arg => { int attemptCount = 0; while (attemptCount < recentFindResults.Length) {