code: def __restore_selection(self, start_pos, end_pos):
          
          cursor = self.textCursor()
          cursor.setPosition(start_pos)
          cursor.setPosition(end_pos, QTextCursor.KeepAnchor)
          self.setTextCursor(cursor)
docs: Restore cursor selection from position bounds