Mikhail Korobov committed b927dff

Fixed group parsing when OPEN_FOLDER is implicit. See GH-5.

Comments (0)

Files changed (1)


             elif divider.type == SectionDivider.BOUNDING_SECTION_DIVIDER:
                 # group ends
-                group_stack.pop()
+                if len(group_stack) == 1:
+                    # This means that there is a BOUNDING_SECTION_DIVIDER
+                    # without an OPEN_FOLDER before it. Create a new group
+                    # and move layers to this new group in this case.
+                    # Assume the first layer is a group
+                    # and convert it to a group:
+                    layers = group_stack[0]['layers']
+                    group = layers[0]
+                    # group doesn't have coords:
+                    for key in 'top', 'left', 'bottom', 'right':
+                        if key in group:
+                            del group[key]
+                    group['layers'] = layers[1:]
+                    group['closed'] = False
+                    # replace moved layers with newly created group:
+                    group_stack[0]['layers'] = [group]
+                else:
+                    finished_group = group_stack.pop()
+                    assert finished_group is not root
                 warnings.warn("invalid state")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.