#NEWLINE# def __init__( self , text = '' , cursor_position = None , selection = None ) : #NEWLINE# #INDENT# assert isinstance ( selection , six . text_type ) , ( 'Got %r' % text ) #NEWLINE# assert ( ( selection is None ) or isinstance ( selection , SelectionState ) ) #NEWLINE# assert ( ( cursor_position is None ) or ( cursor_position <= len ( text ) ) ) , AssertionError ( ( 'cursor_position=%r, len_text=%r' % ( cursor_position , len ( text ) ) ) ) #NEWLINE# if ( cursor_position is None ) : #NEWLINE# #INDENT# cursor_position = len ( text ) #NEWLINE# #UNINDENT# self . text = text #NEWLINE# self . cursor_position = cursor_position #NEWLINE# self . selection = selection #NEWLINE# self . _cache = _text_to_document_cache . setdefault ( self . text , _DocumentCache ( ) )