def edit(self):
        """
        Edit a submission or comment.
        """
        data = self.get_selected_item()
        if data.get('author') != self.reddit.user.name:
            self.term.flash()
            return

        if data['type'] == 'Submission':
            content = data['text']
            info = docs.SUBMISSION_EDIT_FILE.format(
                content=content, id=data['object'].id)
        elif data['type'] == 'Comment':
            content = data['body']
            info = docs.COMMENT_EDIT_FILE.format(
                content=content, id=data['object'].id)
        else:
            self.term.flash()
            return

        with self.term.open_editor(info) as text:
            if not text or text == content:
                self.term.show_notification('Canceled')
                return

            with self.term.loader('Editing', delay=0):
                data['object'].edit(text)
                time.sleep(2.0)

            if self.term.loader.exception is None:
                self.reload_page()
            else:
                raise TemporaryFileError()