From 0b765e075f157be00bb5416ef209956b2727c4c0 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Thu, 30 Jul 2020 14:32:15 -0700 Subject: [PATCH] Add current position to nav stack on initial Find It's fairly common to want to Find something and then jump back to where you were. The Find command now adds the current position to the nav stack for the initial search. If you Find Next, the nav stack is not altered. --- SourceGen/MainController.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/SourceGen/MainController.cs b/SourceGen/MainController.cs index ee9a068..9a1326a 100644 --- a/SourceGen/MainController.cs +++ b/SourceGen/MainController.cs @@ -2466,19 +2466,19 @@ namespace SourceGen { if (dlg.ShowDialog() == true) { mFindString = dlg.TextToFind; mFindStartIndex = -1; - FindText(dlg.IsBackward); + FindText(dlg.IsBackward, true); } } public void FindNext() { - FindText(false); + FindText(false, false); } public void FindPrevious() { - FindText(true); + FindText(true, false); } - private void FindText(bool goBackward) { + private void FindText(bool goBackward, bool pushLocation) { if (string.IsNullOrEmpty(mFindString)) { return; } @@ -2519,6 +2519,10 @@ namespace SourceGen { StringComparison.InvariantCultureIgnoreCase); if (matchPos >= 0) { //Debug.WriteLine("Match " + index + ": " + searchStr); + if (pushLocation) { + mNavStack.Push(GetCurrentlySelectedLocation()); + } + mMainWin.CodeListView_EnsureVisible(index); mMainWin.CodeListView_SelectRange(index, 1); return;