def insert_text(self, data, overwrite=False, move_cursor=True, fire_event=True):
        """
        Insert characters at cursor position.

        :param fire_event: Fire `on_text_insert` event. This is mainly used to
            trigger autocompletion while typing.
        """
        # Original text & cursor position.
        otext = self.text
        ocpos = self.cursor_position

        # In insert/text mode.
        if overwrite:
            # Don't overwrite the newline itself. Just before the line ending,
            # it should act like insert mode.
            overwritten_text = otext[ocpos:ocpos + len(data)]
            if overwritten_text in '\n':
                overwritten_text = overwritten_text[:overwritten_text.find('\n')]

            self.text = otext[:ocpos] + data + otext[ocpos + len(overwritten_text):]
        else:
            self.text = otext[:ocpos] + data + otext[ocpos:]

        if move_cursor:
            self.cursor_position += len(data)

        # Fire 'on_text_insert' event.
        if fire_event:
            self.on_text_insert.fire()
dataset/ETHPy150Open jonathanslenders/python-prompt-toolkit/prompt_toolkit/buffer.py/Buffer.insert_text/swapped operands of `in`