                     event.preventDefault()
                     return true
 
+            # Codemirror return a position given by line/char.
+            # We need to retrieve the lines first
+            query_lines = @codemirror.getValue().split '\n'
+            # Then let's get query before the cursor
+            query_before_cursor = ''
+            if @codemirror.getCursor().line > 0
+                for i in [0..@codemirror.getCursor().line-1]
+                    query_before_cursor += query_lines[i] + '\n'
+            query_before_cursor += query_lines[@codemirror.getCursor().line].slice 0, @codemirror.getCursor().ch
+
+            # Get query after the cursor
+            query_after_cursor = query_lines[@codemirror.getCursor().line].slice @codemirror.getCursor().ch
+            if query_lines.length > @codemirror.getCursor().line+1
+                query_after_cursor += '\n'
+                for i in [@codemirror.getCursor().line+1..query_lines.length-1]
+                    if i isnt query_lines.length-1
+                        query_after_cursor += query_lines[i] + '\n'
+                    else
+                        query_after_cursor += query_lines[i]
+            @query_last_part = query_after_cursor
+
+            # Initialize @current_element, which tracks what the user typed before they hit TAB (to auto-complete).
+            # Tracking this helps us let the user loop over all the suggestions available for the fragment they typed (and go back to the fragment).
+            @current_element = ''
+
+            stack = @extract_data_from_query
+                query: query_before_cursor
+                position: 0
+
+            if @pair_char(event, stack) is true
+                return true
             # If a selection is active, we just catch shift+enter
             if @codemirror.getSelection() isnt ''
                 @hide_suggestion_and_description()

        # Write the suggestion in the code mirror
        write_suggestion: (args) =>
            suggestion_to_write = args.suggestion_to_write
            @codemirror.setValue @query_first_part+suggestion_to_write+@query_last_part
    
            @codemirror.focus() # Useful if the user used the mouse to select a suggestion
            @codemirror.setCursor


            @current_highlighted_suggestion = -1
            @.$('.suggestion_name_list').empty()

            result =
                status: null
