From 457c981a2e6201fa272d2112bdf1d7a8f23977da Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Wed, 10 Oct 2018 17:35:44 -0700 Subject: [PATCH] Fix selection highlight update call Change acf19870 fixed one bug but introduced another: the call to update the highlight happened before the selection was restored, so it could potentially refer to a line that no longer existed. --- SourceGen/AppForms/ProjectView.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SourceGen/AppForms/ProjectView.cs b/SourceGen/AppForms/ProjectView.cs index 911b0e9..864e340 100644 --- a/SourceGen/AppForms/ProjectView.cs +++ b/SourceGen/AppForms/ProjectView.cs @@ -932,6 +932,11 @@ namespace SourceGen.AppForms { string timerStr = mReanalysisTimer.DumpToString("ProjectView timers:"); mShowAnalysisTimersDialog.BodyText = timerStr; } + + // Lines may have moved around. Update the selection highlight. It's important + // we do it here, and not down in DoRefreshProject(), because at that point the + // ListView's selection index could be referencing a line off the end. + UpdateSelectionHighlight(); } /// @@ -1029,7 +1034,6 @@ namespace SourceGen.AppForms { mReanalysisTimer.StartTask("Generate DisplayList"); mDisplayList.GenerateAll(); mReanalysisTimer.EndTask("Generate DisplayList"); - UpdateSelectionHighlight(); } #endregion Project management