def cut_selection(self):
        if self.selection:
            cut_parts = []
            remaining_parts = []
            new_cursor_position = self.cursor_position

            last_to = 0
            for from_, to in self.selection_ranges():
                if last_to == 0:
                    new_cursor_position = from_

                remaining_parts.append(self.text[last_to:from_])
                cut_parts.append(self.text[from_:to + 1])
                last_to = to + 1

            remaining_parts.append(self.text[last_to:])

            cut_text = '\n'.join(cut_parts)
            remaining_text = ''.join(remaining_parts)

            # In case of a LINES selection, don't include the trailing newline.
            if self.selection.type == SelectionType.LINES and cut_text.endswith('\n'):
                cut_text = cut_text[:-1]

            return (Document(text=remaining_text, cursor_position=new_cursor_position),
                    ClipboardData(cut_text, self.selection.type))
        else:
            return self, ClipboardData('')
Remove associated Tornado handler.
dataset/ETHPy150Open jonathanslenders/python-prompt-toolkit/prompt_toolkit/document.py/Document.cut_selection--crossover with--dataset/ETHPy150Open mrjoes/tornadio/tornadio/pollingsession.py/PollingSession.remove_handler