diff --git a/csl.api/src/org/netbeans/modules/csl/navigation/ElementNode.java b/csl.api/src/org/netbeans/modules/csl/navigation/ElementNode.java --- a/csl.api/src/org/netbeans/modules/csl/navigation/ElementNode.java +++ b/csl.api/src/org/netbeans/modules/csl/navigation/ElementNode.java @@ -42,6 +42,7 @@ import java.awt.Image; +import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; @@ -249,6 +250,14 @@ public void updateRecursively( StructureItem newDescription ) { Children ch = getChildren(); + + //If a node that was a LEAF now has children the child type has to be changed from Children.LEAF + //to ElementChildren to be able to hold the new child data + if(!(ch instanceof ElementChildren) && newDescription.getNestedItems().size()>0) { + ch=new ElementChildren((List)Collections.EMPTY_LIST, ui.getFilters(), ui, fileObject); + setChildren(ch); + } + if ( ch instanceof ElementChildren ) { HashSet oldSubs = new HashSet( description.getNestedItems() ); diff --git a/html.editor/src/org/netbeans/modules/html/editor/gsf/HtmlStructureScanner.java b/html.editor/src/org/netbeans/modules/html/editor/gsf/HtmlStructureScanner.java --- a/html.editor/src/org/netbeans/modules/html/editor/gsf/HtmlStructureScanner.java +++ b/html.editor/src/org/netbeans/modules/html/editor/gsf/HtmlStructureScanner.java @@ -277,16 +277,8 @@ } public boolean isLeaf() { - //potentialy incorrect workaround for ElementNode.updateRecursively(StructureItem) method. - //If the StructureItem says it is a leaf then if a new node is created inside - //the navigator representation - ElementNode still holds empty children list - //which is not an instance of ElementChildren and then the subnodes are not refreshed. - //possible fix would be to modify the ElementNode constructor to always create - //ElementChildren even if the node is a leaf, but I am not sure whether it may - //have some bad influence on other things. - return false; - - //return handle.node().children().isEmpty(); + //The child if empty if it hasn't any nested items. If it has only text it's empty. + return getNestedItems().isEmpty(); } @Override