From 02a8edd4ef1efdada60f9c07196811cc2e1fcbb0 Mon Sep 17 00:00:00 2001 From: Benjamin Popp Date: Tue, 15 Jan 2019 21:50:00 -0600 Subject: [PATCH] fix a crash if you try to use back/forward from a search tab. --- .../ViewModels/SearchResultsViewPort.cs | 18 +++++++++--------- src/Gen3Hex.Tests/NavigationTests.cs | 7 +++++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Gen3Hex.Core/ViewModels/SearchResultsViewPort.cs b/src/Gen3Hex.Core/ViewModels/SearchResultsViewPort.cs index 6360ab4c..4d661741 100644 --- a/src/Gen3Hex.Core/ViewModels/SearchResultsViewPort.cs +++ b/src/Gen3Hex.Core/ViewModels/SearchResultsViewPort.cs @@ -55,15 +55,15 @@ namespace HavenSoft.Gen3Hex.Core.ViewModels { } public string Name { get; } public string FileName => string.Empty; - public ICommand Save => null; - public ICommand SaveAs => null; - public ICommand Undo => null; - public ICommand Redo => null; - public ICommand Copy => null; - public ICommand Clear => null; - public ICommand Goto => null; - public ICommand Back => null; - public ICommand Forward => null; + public ICommand Save { get; } = new StubCommand(); + public ICommand SaveAs { get; } = new StubCommand(); + public ICommand Undo { get; } = new StubCommand(); + public ICommand Redo { get; } = new StubCommand(); + public ICommand Copy { get; } = new StubCommand(); + public ICommand Clear { get; } = new StubCommand(); + public ICommand Goto { get; } = new StubCommand(); + public ICommand Back { get; } = new StubCommand(); + public ICommand Forward { get; } = new StubCommand(); public ICommand Close => close; public IModel Model => null; diff --git a/src/Gen3Hex.Tests/NavigationTests.cs b/src/Gen3Hex.Tests/NavigationTests.cs index bfb492e9..7926718b 100644 --- a/src/Gen3Hex.Tests/NavigationTests.cs +++ b/src/Gen3Hex.Tests/NavigationTests.cs @@ -142,6 +142,13 @@ namespace HavenSoft.Gen3Hex.Tests { Assert.Equal("000A00", viewPort.Headers[0]); } + [Fact] + public void CannotBackFromSearchTab() { + var searchTab = new SearchResultsViewPort("bob"); + Assert.False(searchTab.Back.CanExecute(null)); + Assert.False(searchTab.Forward.CanExecute(null)); + } + [Fact] public void BackRecallsYourLastScrollPosition() { var viewPort = new ViewPort(new LoadedFile("test.txt", new byte[0x1000])) { Width = 0x10, Height = 0x10 };