Skip to content

Commit

Permalink
Fix GenerateFoldMarkers
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Nov 22, 2017
1 parent 50024b0 commit fe2d448
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Kaxaml/CodeCompletion/XmlFoldingStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ public List<FoldMarker> GenerateFoldMarkers(IDocument document, string fileName,
{
using (var reader = new XmlTextReader(stringReader))
{
var stack = new Stack();
while (reader.Read())
{
var stack = new Stack();
switch (reader.NodeType)
{
case XmlNodeType.Element:
Expand All @@ -134,8 +134,11 @@ public List<FoldMarker> GenerateFoldMarkers(IDocument document, string fileName,
break;

case XmlNodeType.EndElement:
XmlFoldStart foldStart = (XmlFoldStart)stack.Pop();
CreateElementFold(document, foldMarkers, reader, foldStart);
if (stack.Count > 0)
{
XmlFoldStart foldStart = (XmlFoldStart)stack.Pop();
CreateElementFold(document, foldMarkers, reader, foldStart);
}
break;

case XmlNodeType.Comment:
Expand Down

0 comments on commit fe2d448

Please sign in to comment.