                 ')': '(' # Match the opening character
                 '}': '{'
                 ']': '['
+
+        # Return the type of the last incomplete object or an empty string
+        last_element_type_if_incomplete: (stack) =>
+            if stack.length is 0
+                return ''
+
+            element = stack[stack.length-1]
+            if element.body?
+                return @last_element_type_if_incomplete(element.body)
+            else
+                if element.complete is false
+                    return element.type
+                else
+                    return ''
 
 
         # We build a stack of the query.

                lineNumbers: true
                lineWrapping: true
                matchBrackets: true
            @codemirror.on 'blur', @on_blur
            @codemirror.on 'gutterClick', @handle_gutter_click


            object: /^(\s)*{(\s)*/
            array: /^(\s)*\[(\s)*/
            white: /^(\s)+$/
            white_or_empty: /^(\s)*$/
            white_replace: /\s/g
            white_start: /^(\s)+/
            comma: /^(\s)*,(\s)*/
