Esempio n. 1
0
def should_submit_on_enter(buf):
    """
    Check whether we should submit the buffer, after enter was pressed.
    """
    # This is a bit hacky - we want to look for unmatched brackets in the
    # entire document, but find_enclosing_bracket_left starts from the 
    # current position.  So create a new document.
    doc = Document(buf.document.text, cursor_position=len(buf.document.text))
    if (doc.find_enclosing_bracket_left("(", ")")
        or doc.find_enclosing_bracket_left("[", "]")
        or doc.find_enclosing_bracket_left("{", "}")
        or continue_re.match(doc.current_line)):
        return False
    else:
        return True