From b5deea713fbefd55e0b2792e5f5d4f221e53c9f7 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Tue, 21 Jan 2020 10:29:58 -0800 Subject: [PATCH] Fix adding header comment to project without header lines The DisplayList update function was mis-handling the case where there were no previous lines. This caused assertions to fire for the case where you add a header comment to a project with no existing header comment or EQUs. --- SourceGen/DisplayList.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SourceGen/DisplayList.cs b/SourceGen/DisplayList.cs index 0d7e26f..d7aab7d 100644 --- a/SourceGen/DisplayList.cs +++ b/SourceGen/DisplayList.cs @@ -305,11 +305,13 @@ namespace SourceGen { " new=" + newCount + " (mList.Count=" + mList.Count + ")"); Debug.Assert(startIndex >= 0 && startIndex < mList.Count); - Debug.Assert(oldCount > 0 && startIndex + oldCount <= mList.Count); + Debug.Assert(oldCount >= 0 && startIndex + oldCount <= mList.Count); Debug.Assert(newCount >= 0); // Remove the old elements to clear them. - mList.RemoveRange(startIndex, oldCount); + if (oldCount != 0) { + mList.RemoveRange(startIndex, oldCount); + } // Replace with the appropriate number of null entries. for (int i = 0; i < newCount; i++) { mList.Insert(startIndex, null);