diff --git a/src/Libraries/PythonNodeModelsWpf/TabFoldingStrategy.cs b/src/Libraries/PythonNodeModelsWpf/TabFoldingStrategy.cs index cf72c5c1045..c9b36193f0e 100644 --- a/src/Libraries/PythonNodeModelsWpf/TabFoldingStrategy.cs +++ b/src/Libraries/PythonNodeModelsWpf/TabFoldingStrategy.cs @@ -1,11 +1,8 @@ -using Dynamo.UI.Controls; -using ICSharpCode.AvalonEdit.Document; -using ICSharpCode.AvalonEdit.Folding; using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Windows.Media.Animation; +using ICSharpCode.AvalonEdit.Document; +using ICSharpCode.AvalonEdit.Folding; namespace PythonNodeModelsWpf { @@ -73,7 +70,7 @@ internal IEnumerable CreateNewFoldingsByLine(ITextSource document) } else if (tabLevel != currentTabLevel && currentTabLevel < tabLevel) { - while (currentTabLevel < tabLevel) + while (currentTabLevel < tabLevel && startOffsets.Any()) { // we close all nested tabs var tempFolding = new NewFolding(); @@ -92,7 +89,7 @@ internal IEnumerable CreateNewFoldingsByLine(ITextSource document) } else if (whiteSpaces == 0 && tabLevel > 0) { - while(tabLevel> 0) + while(tabLevel> 0 && startOffsets.Any()) { // we close all nested tabs var tempFolding = new NewFolding();